Exemplo n.º 1
0
 /// <summary>Creates an instance for the default language.</summary>
 /// <returns>A repository.</returns>
 public IColorRepository ForDefaultCulture()
 {
     var colorConverter = new ColorConverter();
     var colorModelConverter = new ColorModelConverter(colorConverter);
     var colorPaletteConverter = new ColorPaletteConverter(colorConverter, colorModelConverter);
     var colorPaletteCollectionConverter = new ColorPaletteCollectionConverter(colorPaletteConverter);
     return new ColorRepository(this.serviceClient, colorPaletteCollectionConverter);
 }
        /// <summary>
        /// Updates the element.
        /// </summary>
        /// <param name="element">Element.</param>
        private void UpdateElement(RoundCornerView element)
        {
            var colorConverter = new ColorConverter();

            Border.Background = (Brush)colorConverter.Convert(element.BackgroundColor, null, null, null);
            Border.BorderBrush = (Brush)colorConverter.Convert(element.BorderColor, null, null, null);
            Border.BorderThickness = new System.Windows.Thickness(element.BorderWidth);
            Border.CornerRadius = new CornerRadius(element.CornerRadius);
        }
        void SetDoughnutValuesCollection()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                ObservableCollection <DoughnutSeriesColl> doughnutValuesCollTemp = new ObservableCollection <DoughnutSeriesColl>();
                DoughnutSeriesColl doughnutSeries;
                foreach (var item in ViolationsKPICollection)
                {
                    doughnutSeries = new DoughnutSeriesColl();
                    doughnutSeries.DoughnutItemColl = new ObservableCollection <DoughnutItem>();
                    doughnutSeries.DoughnutItemColl.Add(new DoughnutItem()
                    {
                        ChartPercentValue = item.ActualPercentage,
                        //ChartPercentValue = ((item.Percentage * 100) * (item.TargetValue / 100)),
                        //? ((item.Percentage * 100) * (item.TargetValue / 100)) : 25,
                        //Percentage = 15,
                        //Color = ((item.ActualPercentage * 100) * (item.TargetValue / 100) >= item.TargetValue ? (Color)ColorConverter.ConvertFromString("#00ffcc") : (Color)ColorConverter.ConvertFromString("#181818"))
                        Color = (item.ActualPercentage >= 100) ? (Color)ColorConverter.ConvertFromString("#00ffcc") : (Color)ColorConverter.ConvertFromString("#181818")
                    });

                    doughnutSeries.DoughnutItemColl.Add(new DoughnutItem()
                    {
                        ChartPercentValue = 100 - (item.ActualPercentage),
                        //Percentage = (item.TargetValue > 0 ? item.TargetValue : 20),
                        Color = (Color)ColorConverter.ConvertFromString("#0a1114")
                    });

                    //doughnutSeries.KpiCategory
                    doughnutSeries.ActPercentage = item.ActualPercentage;
                    doughnutSeries.TargetValue   = item.TargetValue;

                    doughnutSeries.KPIName            = Utility.GetLang() == "ar" ? item.LabelValueArabic : item.LabelValueEnglish;
                    doughnutSeries.ColorActualPercent = new SolidColorBrush((item.ActualPercentage >= 100) ? (Color)ColorConverter.ConvertFromString("#00ffcc") : (Color)ColorConverter.ConvertFromString("#181818"));
                    //doughnutSeries.ColorActualPercent = new SolidColorBrush(((item.ActualPercentage * 100) * (item.TargetValue / 100) >= item.TargetValue ? (Color)ColorConverter.ConvertFromString("#00ffcc") : (Color)ColorConverter.ConvertFromString("#181818")));
                    //doughnutSeries.ColorActualPercent = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0a1114"));
                    doughnutValuesCollTemp.Add(doughnutSeries);
                }
                DoughnutSeriesValueColl = doughnutValuesCollTemp;
            });
        }
Exemplo n.º 4
0
        public void SetSkin()
        {
            switch (Properties.Settings.Default.Themes)
            {
            case "黑色":
                Application.Current.Resources["BackgroundTitle"]  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#22252A"));
                Application.Current.Resources["BackgroundMain"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#393D40"));
                Application.Current.Resources["BackgroundSide"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#323639"));
                Application.Current.Resources["BackgroundTab"]    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#383838"));
                Application.Current.Resources["BackgroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#18191B"));
                Application.Current.Resources["BackgroundMenu"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Black"));
                Application.Current.Resources["ForegroundGlobal"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#AFAFAF"));
                Application.Current.Resources["ForegroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
                Application.Current.Resources["BorderBursh"]      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Transparent"));
                break;

            case "白色":
                Application.Current.Resources["BackgroundTitle"]  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D1D1D1"));
                Application.Current.Resources["BackgroundMain"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
                Application.Current.Resources["BackgroundSide"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E5E5E5"));
                Application.Current.Resources["BackgroundTab"]    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFF5EE"));
                Application.Current.Resources["BackgroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAE8"));
                Application.Current.Resources["BackgroundMenu"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White"));
                Application.Current.Resources["ForegroundGlobal"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#555555"));
                Application.Current.Resources["ForegroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000000"));
                Application.Current.Resources["BorderBursh"]      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Gray"));
                break;

            case "蓝色":
                Application.Current.Resources["BackgroundTitle"]  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0B72BD"));
                Application.Current.Resources["BackgroundMain"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#87CEFF"));
                Application.Current.Resources["BackgroundSide"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3DBEDE"));
                Application.Current.Resources["BackgroundTab"]    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3DBEDE"));
                Application.Current.Resources["BackgroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#87CEEB"));
                Application.Current.Resources["BackgroundMenu"]   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("LightBlue"));
                Application.Current.Resources["ForegroundGlobal"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White"));
                Application.Current.Resources["ForegroundSearch"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White"));
                Application.Current.Resources["BorderBursh"]      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#95DCED"));
                break;
            }
        }
Exemplo n.º 5
0
        public IDEEditor(FileBaseItem aItem)
        {
            InitializeComponent();
            item          = aItem;
            changeChecker = new DataChanged {
                editor = editor
            };
            SetCode(aItem);
            editor.ShowLineNumbers = true;

            editor.Options.ConvertTabsToSpaces = true;
            editor.Options.IndentationSize     = 4;

            editor.FontFamily = new FontFamily("Consolas");
            editor.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFDCDCCC"));
            editor.TextArea.TextView.BackgroundRenderers.Add(new LineHighlighter());
            editor.TextArea.TextView.BackgroundRenderers.Add(new ErrorLineHighlighter(aItem));
            // Buggy
            //editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy();
            Debugger.Editor.SearchPanel.Install(editor);
            editor.TextChanged += editor_TextChanged;
            scanner             = new DepthScanner();
            scanner.Process(editor.Text);
            editor.MouseHover          += editor_MouseHover;
            editor.TextArea.MouseWheel += editor_MouseWheel;
            editor.KeyUp   += editor_KeyUp;
            editor.MouseUp += editor_MouseUp;
            codeFolding     = new BraceFoldingStrategy();

            if (FOLDED_EXTENSIONS.Contains(System.IO.Path.GetExtension(aItem.Path)))
            {
                foldingManager = FoldingManager.Install(editor.TextArea);
                UpdateFoldings();
            }

            intelSource        = Intellisense.Sources.SourceBuilder.GetSourceForExtension(System.IO.Path.GetExtension(item.Path));
            editor.ContextMenu = new ContextMenu();

            // Hook the source, so we can get context menu commands from it
            if (intelSource != null)
            {
                intelSource.HookEditor(editor, item);
            }

            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "Snippet",
                Command = new RelayCommand(p =>
                {
                    ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>();
                    string ext = System.IO.Path.GetExtension(item.Path);
                    foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets)
                    {
                        if (snip.Extension.Equals(ext))
                        {
                            snips.Add(snip);
                        }
                    }
                    if (snips.Count > 0)
                    {
                        Snippets.SnippetDlg dlg = new Snippets.SnippetDlg(editor, snips);
                        dlg.ShowDialog();
                    }
                }, sp =>
                {
                    ObservableCollection <Snippets.CodeSnippet> snips = new ObservableCollection <Snippets.CodeSnippet>();
                    string exte = System.IO.Path.GetExtension(item.Path);
                    foreach (Snippets.CodeSnippet snip in Snippets.SnippetData.inst().Snippets)
                    {
                        if (snip.Extension.Equals(exte))
                        {
                            return(true);
                        }
                    }
                    return(false);
                })
            });

            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Cut",
                Command = ApplicationCommands.Cut
            });
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Copy",
                Command = ApplicationCommands.Copy
            });
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Paste",
                Command = ApplicationCommands.Paste
            });
            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Undo",
                Command = ApplicationCommands.Undo
            });
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Redo",
                Command = ApplicationCommands.Redo
            });
            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Save",
                Command = ApplicationCommands.Save
            });
            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Save As",
                Command = ApplicationCommands.SaveAs
            });
            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem {
                Header  = "Open",
                Command = ApplicationCommands.Open
            });
        }
Exemplo n.º 6
0
        // POST api/image
        public async Task <HttpResponseMessage> Post()
        {
            string root     = HttpContext.Current.Server.MapPath("~/App_Data");
            var    provider = new MultipartFormDataStreamProvider(root);
            Guid   zipId    = Guid.NewGuid();

            try
            {
                // Read the form data.
                await Request.Content.ReadAsMultipartAsync(provider);

                MultipartFileData multipartFileData = provider.FileData.First();

                using (var model = new IconModel())
                {
                    var ct = multipartFileData.Headers.ContentType.MediaType;
                    if (ct != null && ct.Contains("svg"))
                    {
                        model.SvgFile = multipartFileData.LocalFileName;
                    }
                    else
                    {
                        model.InputImage = Image.FromFile(multipartFileData.LocalFileName);
                    }
                    model.Padding = Convert.ToDouble(provider.FormData.GetValues("padding")[0]);
                    if (model.Padding < 0 || model.Padding > 1.0)
                    {
                        // Throw out as user has supplied invalid hex string..
                        HttpResponseMessage httpResponseMessage =
                            Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Padding value invalid. Please input a number between 0 and 1");
                        return(httpResponseMessage);
                    }

                    var colorStr     = provider.FormData.GetValues("color")?[0];
                    var colorChanged = provider.FormData.GetValues("colorChanged")?[0] == "1";

                    if (!string.IsNullOrEmpty(colorStr) && colorChanged)
                    {
                        try
                        {
                            var colorConverter = new ColorConverter();
                            model.Background = (Color)colorConverter.ConvertFromString(colorStr);
                        }
                        catch (Exception ex)
                        {
                            // Throw out as user has supplied invalid hex string..
                            HttpResponseMessage httpResponseMessage =
                                Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Background Color value invalid. Please input a valid hex color.", ex);
                            return(httpResponseMessage);
                        }
                    }

                    var platforms = provider.FormData.GetValues("platform");

                    if (platforms == null)
                    {
                        // Throw out as user has supplied no platforms..
                        HttpResponseMessage httpResponseMessage =
                            Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No platform has been specified.");
                        return(httpResponseMessage);
                    }

                    model.Platforms = platforms;

                    List <Profile> profiles = null;

                    foreach (var platform in model.Platforms)
                    {
                        // Get the platform and profiles
                        IEnumerable <string> config = GetConfig(platform);
                        if (config.Count() < 1)
                        {
                            throw new HttpResponseException(HttpStatusCode.BadRequest);
                        }

                        foreach (var cfg in config)
                        {
                            if (profiles == null)
                            {
                                profiles = JsonConvert.DeserializeObject <List <Profile> >(cfg);
                            }
                            else
                            {
                                profiles.AddRange(JsonConvert.DeserializeObject <List <Profile> >(cfg));
                            }
                        }
                    }

                    using (var zip = new ZipFile())
                    {
                        var iconObject = new IconRootObject();
                        foreach (var profile in profiles)
                        {
                            var stream = CreateImageStream(model, profile);

                            string fmt = string.IsNullOrEmpty(profile.Format) ? "png" : profile.Format;
                            zip.AddEntry(profile.Folder + profile.Name + "." + fmt, stream);
                            stream.Flush();

                            iconObject.icons.Add(new IconObject(profile.Folder + profile.Name + "." + fmt, profile.Width + "x" + profile.Height));
                        }

                        var iconStr = JsonConvert.SerializeObject(iconObject, Formatting.Indented);

                        zip.AddEntry("icons.json", iconStr);

                        string zipFilePath = CreateFilePathFromId(zipId);
                        zip.Save(zipFilePath);
                    }
                }

                // Delete source image file from local disk
                File.Delete(multipartFileData.LocalFileName);
            }
            catch (OutOfMemoryException ex)
            {
                HttpResponseMessage httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.UnsupportedMediaType, ex);
                return(httpResponseMessage);
            }
            catch (Exception ex)
            {
                HttpResponseMessage httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
                return(httpResponseMessage);
            }

            string url = Url.Route("DefaultApi", new { controller = "image", id = zipId.ToString() });

            var uri             = new Uri(url, UriKind.Relative);
            var responseMessage = Request.CreateResponse(HttpStatusCode.Created,
                                                         new ImageResponse {
                Uri = uri
            });

            responseMessage.Headers.Location = uri;

            return(responseMessage);
        }
Exemplo n.º 7
0
        protected virtual void ThumbProcessing()
        {
            double ld = Math.Log(2);
            long index = 0;
            ColorRGB crgb = new ColorRGB(new RGBColorspacesRGB());
            ColorLab cl = new ColorLab();
            ConversionRoutine routLab = ColorConverter.FindRoutine(crgb, cl);
            ConversionRoutine routRGB = ColorConverter.FindRoutine(cl, crgb);
            BitmapEx bmp, bmpE;

            using (ColorConverter Converter = new ColorConverter())
            {
                for (int i = 0; i < Frames.Count; i++)
                {
                    double exposure = Math.Log(Frames[i].NewBrightness / Frames[i].AlternativeBrightness, 2);
                    bmp = GetThumb(i, false);
                    bmpE = GetThumbEdited(i, false);

                    unsafe
                    {
                        bmp.LockBits();
                        bmpE.LockBits();
                        byte* pix1 = (byte*)bmp.Scan0;
                        byte* pix2 = (byte*)bmpE.Scan0;

                        for (uint y = 0; y < bmp.Height; y++)
                        {
                            for (uint x = 0; x < bmp.Stride; x += bmp.ChannelCount)
                            {
                                index = y * bmp.Stride + x;

                                //LTODO: doesn't calculate correctly
                                crgb.R = pix1[index] / 255d; crgb.G = pix1[index + 1] / 255d; crgb.B = pix1[index + 2] / 255d;
                                Converter.Convert(crgb, cl, routLab);
                                if (exposure < 0) { cl.L = (cl.L < 0.94) ? cl.L : Math.Exp(exposure * ld) * cl.L; }
                                else if (exposure > 0) { cl.L = (cl.L > 0.06) ? cl.L : Math.Exp(exposure * ld) * cl.L; }
                                Converter.Convert(cl, crgb, routRGB);

                                pix2[index] = (byte)(crgb.R * byte.MaxValue);
                                pix2[index + 1] = (byte)(crgb.G * byte.MaxValue);
                                pix2[index + 2] = (byte)(crgb.B * byte.MaxValue);
                            }
                        }
                        bmp.UnlockBits();
                        bmpE.UnlockBits();
                    }

                    SetThumbEdited(i, bmpE);
                    MainWorker.ReportProgress(0, new ProgressChangeEventArgs(i * 100 / (Frames.Count - 1), ProgressType.ProcessingThumbs));
                }
            }
        }
 public void SetAppColor(string resourceName, string color)
 {
     App.Current.Resources[resourceName] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
 }
Exemplo n.º 9
0
        public Detail(string code)
        {
            InitializeComponent();
            code += "\n";
            resultView.ItemsSource = currentRenderLayers;
            treeView.ItemsSource   = treeRenderLayers;
            colorScheme            = colorNames.Select(s => (Color)ColorConverter.ConvertFromString(s)).ToArray();
            colorlist = new List <Brush>
            {
                Brushes.Green,
                Brushes.Orange,
                Brushes.Pink,
                Brushes.Purple,
                Brushes.Blue
            };
            TextBlockBorderThickness = 1;
            BigStackPanel.Margin     = new Thickness(TextBlockBorderThickness);
            //Random rnd = new Random();

            /*
             * 使用tempstackpanellist处理临时stackpanel的回收问题
             * 节点范围跨行,即当做方框型
             * 树节点数据结构:father, linenum, left, right
             *  linenum为-1,此为跨行节点,left到right行
             *  否则不跨行,linenum行第left列到right列的token
             */
            string [] input;
            try
            {
                input      = CompilerInvoker.Compile(code).Replace("\r", "").Split('\n').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
                TreeOutput = CompilerInvoker.Compile(code, true).Replace("\r", "").Split('\n').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray();
            }
            catch
            {
                throw;
            }
            TotalNodeNum = Convert.ToInt32(input[0]);
            nodes        = new List <RawNode>();
            for (int i = TotalNodeNum; i > 0; i--)
            {
                nodes.Add(new RawNode()
                {
                    Father = -1, FatherLinkType = "root"
                });
            }
            List <ImportantPos> poslist = new List <ImportantPos>();

            for (int i = 1; i < input.Length; i++)
            {
                var part       = Regex.Split(input[i], @"\s");
                int nowpartpos = 6;
                int nowid      = Convert.ToInt32(part[0]);
                nodes[nowid].TypeMacro = Convert.ToInt32(part[1]);
                nodes[nowid].TypeName  = part[2];
                int          startpos = Convert.ToInt32(part[3]);
                int          endpos   = startpos + Convert.ToInt32(part[4]);
                ImportantPos ipstart  = new ImportantPos()
                {
                    IsStart = true,
                    NodeId  = nowid,
                    Pos     = startpos
                };
                ImportantPos ipend = new ImportantPos()
                {
                    IsStart = false,
                    NodeId  = nowid,
                    Pos     = endpos
                };
                poslist.Add(ipstart);
                poslist.Add(ipend);
                int childnum = Convert.ToInt32(part[5]);
                nodes[nowid].ChildrenCount = childnum;
                for (; childnum > 0; childnum--)
                {
                    int    childid         = Convert.ToInt32(part[nowpartpos++]);
                    string childlinestring = part[nowpartpos++];
                    nodes[childid].Father         = nowid;
                    nodes[childid].FatherLinkType = childlinestring;
                }
            }
            poslist.Sort();
            int codeposoffset = 0, nowpos = 0, nowcodeline = 0;
            var codeslinesplit = Regex.Split(code, @"\n");

            int[] codebelong   = new int[code.Length];
            int[] linestartpos = new int[codeslinesplit.Length + 1];
            linestartpos[codeslinesplit.Length] = code.Length;
            for (int i = 0; i < codebelong.Length; i++)
            {
                codebelong[i] = -1;
            }
            for (;;)
            {
                if (nowpos >= poslist.Count && nowcodeline >= codeslinesplit.Length)
                {
                    break;
                }
                linestartpos[nowcodeline] = codeposoffset;
                int start = codeposoffset, end = codeposoffset + codeslinesplit[nowcodeline].Length + 1;
                for (; nowpos < poslist.Count && poslist[nowpos].Pos < end; nowpos++)
                {
                    var pos = poslist[nowpos];
                    if (pos.IsStart)
                    {
                        nodes[pos.NodeId].LineNumber  = nowcodeline;
                        nodes[pos.NodeId].Left        = pos.Pos - codeposoffset;
                        nodes[pos.NodeId].OneLineLeft = pos.Pos;
                    }
                    else
                    {
                        nodes[pos.NodeId].OneLineRight = pos.Pos;
                        //for (int i = nodes[pos.NodeId].OneLineLeft; i < nodes[pos.NodeId].OneLineRight; i++)
                        //    if (codebelong[i] == -1)
                        //        codebelong[i] = pos.NodeId;
                        if (nowcodeline == nodes[pos.NodeId].LineNumber)
                        {
                            nodes[pos.NodeId].Right = pos.Pos - codeposoffset;
                        }
                        else
                        {
                            nodes[pos.NodeId].Left       = nodes[pos.NodeId].LineNumber;
                            nodes[pos.NodeId].LineNumber = -1;
                            nodes[pos.NodeId].Right      = nowcodeline + 1;
                        }
                    }
                }
                codeposoffset = end;
                nowcodeline++;
            }
            foreach (var pos in poslist)
            {
                if (!pos.IsStart)
                {
                    for (int i = nodes[pos.NodeId].OneLineLeft; i < nodes[pos.NodeId].OneLineRight; i++)
                    {
                        if (codebelong[i] == -1 || IsFather(codebelong[i], pos.NodeId))
                        {
                            codebelong[i] = pos.NodeId;
                        }
                    }
                }
            }
            for (int i = 0; i < codeslinesplit.Length; i++)
            {
                StackPanel       sp       = new StackPanel();
                List <TextBlock> ltb      = new List <TextBlock>();
                List <Border>    lb       = new List <Border>();
                bool             allspace = true;
                int offset = linestartpos[i];
                int lastcolor = offset < codebelong.Length ? codebelong[offset] : -2, startpos = offset;
                for (int j = offset; j < linestartpos[i + 1]; j++)
                {
                    if (codebelong[j] != lastcolor || j == linestartpos[i + 1] - 1 || (allspace && j != startpos))
                    {
                        TextBlock tb = new TextBlock()
                        {
                            Text       = code.Substring(startpos, j - startpos),
                            Tag        = lastcolor,
                            FontFamily = new FontFamily("Courier New")
                        };
                        //tb.Background = colorlist[rnd.Next() % colorlist.Count];
                        //tb.Background = colorlist[rand];
                        //rand = (rand + 1) % colorlist.Count;
                        Border b = new Border()
                        {
                            BorderThickness = new Thickness(0),
                            Margin          = new Thickness(0),
                            BorderBrush     = Brushes.Transparent,
                            Tag             = lastcolor,
                            Child           = tb
                        };
                        if (!allspace)
                        {
                            tb.MouseMove += TextBlockWithBorder_MouseMove;
                            b.MouseMove  += TextBlockWithBorder_MouseMove;
                        }
                        ltb.Add(tb);
                        lb.Add(b);
                        sp.Children.Add(b);
                        lastcolor = codebelong[j];
                        startpos  = j;
                    }
                    if (code[j] != ' ')
                    {
                        allspace = false;
                    }
                }
                sp.Orientation         = Orientation.Horizontal;
                sp.Height              = 22;
                sp.HorizontalAlignment = HorizontalAlignment.Left;
                smallstackpanels.Add(sp);
                textblocks.Add(ltb);
                borders.Add(lb);
            }
            foreach (var i in smallstackpanels)
            {
                BigStackPanel.Children.Add(i);
            }

            VisualizeTreeOutput();

            for (int i = 0; i < codeslinesplit.Length; i++)
            {
                TextBlock tb = new TextBlock()
                {
                    Text       = breakPointString,
                    Foreground = Brushes.Transparent,
                    FontFamily = new FontFamily("新宋体"),
                    Height     = 22
                };
                tb.MouseDown += BreakPoint_MouseDown;
                BreakPointStackPanel.Children.Add(tb);
            }

            //RandBlock(ref BigStackPanel, 0, smallstackpanels.Count, 0);
            Mediator.Instance.Code = code;
            runningProgram         = false;
        }
Exemplo n.º 10
0
 public override IDataGridFilter GetFilter()
 {
     var colorsFilter = new DataGridMultiValueFilter();
     colorsFilter.ItemTemplate = XamlReader.Parse(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:local=""clr-namespace:DataGridSamples;assembly=" + new AssemblyName(Assembly.GetExecutingAssembly().FullName).Name + @""" xmlns:c1=""http://schemas.componentone.com/winfx/2006/xaml"">
     <StackPanel Orientation=""Horizontal"">
         <StackPanel.Resources>
             <local:ColorConverter x:Key=""colorConverter""/>
         </StackPanel.Resources>
         <c1:C1CheckeredBorder BorderThickness=""1"" BorderBrush=""Black"" Background=""{Binding Converter={StaticResource colorConverter}}"" Width=""12"" Height=""12"" VerticalAlignment=""Center""/>
         <TextBlock Text=""{Binding}"" VerticalAlignment=""Center"" Margin=""2 0 0 0 ""/>
     </StackPanel>
     </DataTemplate>") as DataTemplate;
     colorsFilter.SetBinding(DataGridMultiValueFilter.ItemsSourceProperty, new Binding("ItemsSource")
     {
         Source = DataGrid,
         Converter = CustomConverter.Create((value, type, parameter, culture) =>
         {
             if (value is IEnumerable)
             {
                 var enumerable = ((IEnumerable)value).Cast<object>();
                 var colorConverter = new ColorConverter();
                 return enumerable.Select(o => C1DataGridFilterHelper.GetPropertyValue<object>(o, FilterMemberPath)).Distinct().Select(o => (Color)colorConverter.Convert(o, typeof(Color), null, CultureInfo.CurrentCulture)).OrderBy(c => new C1HslColor(c).Hue);
             }
             return value;
         })
     });
     colorsFilter.SetBinding(DataGridMultiValueFilter.BackgroundProperty, new Binding("HeaderBackground") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.ForegroundProperty, new Binding("HeaderForeground") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.BorderBrushProperty, new Binding("BorderBrush") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.MouseOverBrushProperty, new Binding("MouseOverBrush") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.PressedBrushProperty, new Binding("PressedBrush") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.FocusBrushProperty, new Binding("SelectedBackground") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.InputBackgroundProperty, new Binding("RowBackground") { Source = DataGrid });
     colorsFilter.SetBinding(DataGridMultiValueFilter.InputForegroundProperty, new Binding("RowForeground") { Source = DataGrid });
     var filter = new DataGridContentFilter
     {
         Content = new DataGridFilterList
         {
             Items = new List<IDataGridFilterUnity>
             {
                 new DataGridTextFilter(),
                 colorsFilter,
             }
         }
     };
     return filter;
 }
    public void sendEmail()
    {
        whitfield_prod_reports _wRep = new whitfield_prod_reports();
        MailMessage message = new MailMessage();

        message.To.Add(System.Configuration.ConfigurationManager.AppSettings["devEmail"]);

        //using (IDataReader reader = u.GetMSIRAdminRecords())  //HHS Uncomment this portion when there is an email list.
        //{
        //    while (reader.Read())
        //    {
        //        message.To.Add(reader["EMAIL_ADDRESS"].ToString());
        //    }
        //}

        message.To.Add(System.Configuration.ConfigurationManager.AppSettings["AdminEmail"].ToString());
        //message.To.Add(System.Configuration.ConfigurationManager.AppSettings["PMEmail"].ToString());
        message.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["DPR_fromEmail"]);
        message.Subject = "Daily Production report for " + txtReportDate.Text.Trim();
        message.IsBodyHtml = true;

        StringBuilder sb = new StringBuilder();
        sb.Append("<html><head></head>");
        sb.Append("<body>");
        //Header
        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD><IMG height='80' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/TWC%20Primary%20Logo1.JPG' border='0'></TD>");
        sb.Append("<TD class='form1' vAlign='bottom' align='right' width='100%'><b>The Whitfield Company, Inc.<br>");
        sb.Append("8836 Washington Blvd., Ste 101<br>");
        sb.Append("Jessup, MD 20794<br>");
        sb.Append("(301)-483-0791<br>");
        sb.Append("(301)-483-0792</b><br>");
        sb.Append("<IMG height='9' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/images.gif' width='1'>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD>");
        //sb.Append("<br><b>Following is the Daily Production report for " + txtReportDate.Text.Trim() + "</b>");
        //Significant Issues/Impediments Notes/Comments
        sb.Append("<br><b>Significant Issues/Impediments Notes/Comments:</b>" + txtRptIssues.Text.Trim() + "<br>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        //Activity
        DataGrid dg = new DataGrid();
        dg.Font.Size = 9;
        dg.CssClass = "data";
        System.Drawing.ColorConverter colConvert = new ColorConverter();

        dg.HeaderStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#60829F");
        dg.HeaderStyle.CssClass = "subnav";
        dg.HeaderStyle.Font.Bold = true;
        dg.ItemStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#EAEFF3");
        dg.ItemStyle.Font.Bold = true;
        dg.FooterStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#D9D9D9");

        dg.DataSource = _wRep.GetReportActivityForProjectForEmail(_wRep.GetReportNumber(txtReportDate.Text.Trim()));
        dg.DataBind();
        StringBuilder SBActivity = new StringBuilder();
        StringWriter SWActivity = new StringWriter(SBActivity);
        HtmlTextWriter htmlTWActivity = new HtmlTextWriter(SWActivity);
        dg.RenderControl(htmlTWActivity);
        string ActivityString = SBActivity.ToString();

        //EmployeeHours
        StringBuilder SBEmployeeHours = new StringBuilder();
        StringWriter SWEmployeeHours = new StringWriter(SBEmployeeHours);
        HtmlTextWriter htmlTWEmployeeHours = new HtmlTextWriter(SWEmployeeHours);
        grdEmployeeHours.RenderControl(htmlTWEmployeeHours);
        string EmployeeHoursString = SBEmployeeHours.ToString();
        sb.Append("<br><b>Employee Hours:</b><br>" + EmployeeHoursString + "<br><b>Employee Activity:</b><br>" + ActivityString);
        sb.Append("</body></html>");
        message.Body = sb.ToString();
        SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["smtp"]);
        smtp.Send(message);
    }
Exemplo n.º 12
0
 /// <summary>Creates an instance for the given language.</summary>
 /// <param name="culture">The culture.</param>
 /// <returns>A repository.</returns>
 public IColorRepository ForCulture(CultureInfo culture)
 {
     var colorConverter = new ColorConverter();
     var colorModelConverter = new ColorModelConverter(colorConverter);
     var colorPaletteConverter = new ColorPaletteConverter(colorConverter, colorModelConverter);
     var colorPaletteCollectionConverter = new ColorPaletteCollectionConverter(colorPaletteConverter);
     IColorRepository repository = new ColorRepository(this.serviceClient, colorPaletteCollectionConverter);
     repository.Culture = culture;
     return repository;
 }
Exemplo n.º 13
0
        /// <summary>
        /// Populates the settings panel with the settings of a given plugin.
        /// </summary>
        /// <param name="plugin">The plugin whose settings to display</param>
        private void PopulateSettings(Plugin plugin)
        {
            SettingsGrid.RowDefinitions.Clear();
            SettingsGrid.Children.Clear();

            for (int i = 0; i < plugin.Settings.Count; i++)
            {
                Setting s = plugin.Settings[i];

                // add row
                SettingsGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

                // create label
                TextBlock tb = new TextBlock()
                {
                    Text = plugin.T(s.ID),
                    Margin = new Thickness(5, 5, 10, 5),
                    VerticalAlignment = VerticalAlignment.Center
                };

                tb.SetBinding(TextBlock.VisibilityProperty, new Binding("IsVisible")
                {
                    Source = s,
                    Mode = BindingMode.OneWay,
                    Converter = new BooleanToVisibilityConverter()
                });

                Grid.SetRow(tb, i);
                Grid.SetColumn(tb, 0);
                SettingsGrid.Children.Add(tb);

                FrameworkElement control = null;

                // create control
                if (s.Type == typeof(Boolean))
                {
                    // checkbox
                    control = new CheckBox() { Height = 15 };
                    control.SetBinding(CheckBox.IsCheckedProperty, new Binding("Value")
                    {
                        Source = s,
                        Mode = BindingMode.TwoWay
                    });
                }
                else if (s.Type == typeof(Color))
                {
                    // color selector
                    control = new ColorPicker()
                    {
                        ShowAvailableColors = false,
                        ShowStandardColors = true,
                        Width = 50,
                    };
                    if (s.PossibleValues != null)
                    {
                        ColorConverter converter = new ColorConverter();
                        ((ColorPicker)control).AvailableColors.Clear();
                        foreach (Color c in s.PossibleValues)
                        {
                            System.Windows.Media.Color color = (System.Windows.Media.Color)converter.Convert(c, null, null, null);
                            ((ColorPicker)control).AvailableColors.Add(new ColorItem(color, c.Name));
                        }
                    }
                    control.SetBinding(ColorPicker.SelectedColorProperty, new Binding("Value")
                    {
                        Source = s,
                        Mode = BindingMode.TwoWay,
                        Converter = new ColorConverter()
                    });
                }
                else if (s.PossibleValues != null)
                {
                    // dropdown
                    control = new ComboBox();
                    foreach (Object val in s.PossibleValues)
                    {
                        try
                        {
                            String content = val.ToString();
                            if (s.Type == typeof(String))
                                content = plugin.T(val.ToString());
                            ((ComboBox)control).Items.Add(new ComboBoxItem
                            {
                                Content = content,
                                Name = val.ToString()
                            });
                        }
                        catch (Exception exc)
                        {
                            U.L(LogLevel.Warning, "PLUGIN", "Could not add combobox item in plugin settings: " + exc.Message);
                        }
                    }
                    ((ComboBox)control).SelectedValuePath = "Name";
                    control.SetBinding(ComboBox.SelectedValueProperty, new Binding("Value")
                    {
                        Source = s,
                        Mode = BindingMode.TwoWay
                    });
                }
                else if (s.Type == typeof(String))
                {
                    // text input
                    control = new TextBox()
                    {
                        MaxWidth = 400,
                        MinWidth = 250
                    };
                    control.SetBinding(TextBox.TextProperty, new Binding("Value")
                    {
                        Source = s,
                        Mode = BindingMode.TwoWay
                    });
                }
                else if (s.Type == typeof(Int32))
                {
                    if (s.Maximum != null)
                    {
                        // slider
                        control = new Slider()
                        {
                            Maximum = (Int32)s.Maximum,
                            AutoToolTipPlacement = AutoToolTipPlacement.TopLeft,
                            Width = 200,
                        };
                        if (s.Minimum != null)
                            ((Slider)control).Minimum = (Int32)s.Minimum;
                        control.SetBinding(Slider.ValueProperty, new Binding("Value")
                        {
                            Source = s,
                            Mode = BindingMode.TwoWay
                        });
                    }
                    else
                    {
                        // spinner
                        control = new IntegerUpDown();
                        control.SetBinding(IntegerUpDown.ValueProperty, new Binding("Value")
                        {
                            Source = s,
                            Mode = BindingMode.TwoWay
                        });
                    }
                }
                else if (s.Type == typeof(Double))
                {
                    if (s.Maximum != null)
                    {
                        // slider
                        control = new Slider()
                        {
                            Maximum = (Double)s.Maximum,
                            AutoToolTipPlacement = AutoToolTipPlacement.TopLeft,
                            Width = 200,
                        };
                        if (s.Minimum != null)
                            ((Slider)control).Minimum = (Double)s.Minimum;
                        control.SetBinding(Slider.ValueProperty, new Binding("Value")
                        {
                            Source = s,
                            Mode = BindingMode.TwoWay
                        });
                    }
                    else
                    {
                        // spinner
                        control = new DoubleUpDown();
                        control.SetBinding(DoubleUpDown.ValueProperty, new Binding("Value")
                        {
                            Source = s,
                            Mode = BindingMode.TwoWay
                        });
                    }
                }

                if (control != null)
                {
                    control.Margin = new Thickness(0, 5, 0, 5);
                    control.VerticalAlignment = VerticalAlignment.Center;
                    control.HorizontalAlignment = HorizontalAlignment.Left;

                    control.SetBinding(FrameworkElement.VisibilityProperty, new Binding("IsVisible")
                    {
                        Source = s,
                        Mode = BindingMode.OneWay,
                        Converter = new BooleanToVisibilityConverter()
                    });

                    Grid.SetRow(control, i);
                    Grid.SetColumn(control, 1);
                    SettingsGrid.Children.Add(control);
                }
            }
        }
Exemplo n.º 14
0
        private void BrCalc_Lab()
        {
            BitmapEx bmp1, bmp2, bmp3;
            const int min = 5;
            const int max = 95;

            bmp1 = GetThumb(0, true);

            const uint ThumbWidth = 300;
            const uint ThumbHeight = 200;
            uint rowstride;
            int n = bmp1.ChannelCount;

            long index = 0;
            uint x, y;
            int x1, y1, maxCol = 8;
            double fact, d1, d2;
            List<double[]> PixelBrightness;
            bool[,] NonUseMask = new bool[ThumbWidth, ThumbHeight];

            using (ColorConverter Converter = new ColorConverter())
            {
                ColorLab[,] labimg1 = new ColorLab[ThumbWidth, ThumbHeight];
                ColorLab[,] labimg2 = new ColorLab[ThumbWidth, ThumbHeight];
                ColorLab[,] labimg3 = new ColorLab[ThumbWidth, ThumbHeight];
                ColorRGB colrgb = new ColorRGB(new RGBColorspacesRGB());
                ConversionRoutine rout = ColorConverter.FindRoutine(colrgb, labimg1[0, 0]);

                for (int f = 1; f < Frames.Count; f += 2)
                {
                    if (MainWorker.CancellationPending) { return; }

                    if (f + 2 >= Frames.Count) { f = Frames.Count - 2; }

                    bmp1 = GetThumb(f - 1, false).Scale(ThumbWidth, ThumbHeight);
                    bmp2 = GetThumb(f, false).Scale(ThumbWidth, ThumbHeight);
                    bmp3 = GetThumb(f + 1, false).Scale(ThumbWidth, ThumbHeight);
                    rowstride = bmp1.Stride;

                    unsafe
                    {
                        bmp1.LockBits();
                        bmp2.LockBits();
                        bmp3.LockBits();

                        byte* pix1 = (byte*)bmp1.Scan0;
                        byte* pix2 = (byte*)bmp2.Scan0;
                        byte* pix3 = (byte*)bmp3.Scan0;

                        //Non use Mask and Lab conversion
                        for (y = 0; y < ThumbHeight; y++)
                        {
                            for (x = 0; x < ThumbWidth; x++)
                            {
                                index = y * rowstride + (x * n);

                                colrgb.R = pix1[index];
                                colrgb.G = pix1[index + 1];
                                colrgb.B = pix1[index + 2];
                                Converter.Convert(colrgb, labimg1[x, y], rout);
                                colrgb.R = pix2[index];
                                colrgb.G = pix2[index + 1];
                                colrgb.B = pix2[index + 2];
                                Converter.Convert(colrgb, labimg2[x, y], rout);
                                colrgb.R = pix3[index];
                                colrgb.G = pix3[index + 1];
                                colrgb.B = pix3[index + 2];
                                Converter.Convert(colrgb, labimg3[x, y], rout);

                                if (labimg1[x, y].L < min || labimg1[x, y].L > max || labimg2[x, y].L < min || labimg2[x, y].L > max || labimg3[x, y].L < min || labimg3[x, y].L > max ||
                                    Math.Abs(labimg2[x, y].a - labimg1[x, y].a) > maxCol || Math.Abs(labimg3[x, y].a - labimg2[x, y].a) > maxCol ||
                                    Math.Abs(labimg2[x, y].b - labimg1[x, y].b) > maxCol || Math.Abs(labimg3[x, y].b - labimg2[x, y].b) > maxCol)
                                {
                                    NonUseMask[x, y] = true;
                                }
                            }
                        }
                        bmp1.UnlockBits();
                        bmp2.UnlockBits();
                        bmp3.UnlockBits();
                    }

                    PixelBrightness = new List<double[]>();

                    //Brightness calculation
                    for (y = 0; y < ThumbHeight; y++)
                    {
                        for (x = 0; x < ThumbWidth; x++)
                        {
                            if (!NonUseMask[x, y])
                            {
                                fact = 0;
                                if (y > 0 && x > 0 && y < ThumbHeight - 1 && x < ThumbWidth - 1)
                                {
                                    d1 = 0;
                                    d2 = 0;
                                    for (y1 = -1; y1 <= 1; y1++)
                                    {
                                        for (x1 = -1; x1 <= 1; x1++)
                                        {
                                            d1 += Math.Abs(labimg1[x, y].L - labimg2[x, y].L);
                                            d2 += Math.Abs(labimg2[x, y].L - labimg3[x, y].L);
                                        }
                                    }
                                    fact = Math.Max(d1 / 9d, d2 / 9d);
                                }
                                if (fact > 0.2) PixelBrightness.Add(new double[] { fact * Math.Log(labimg1[x, y].L), fact * Math.Log(labimg2[x, y].L), fact * Math.Log(labimg3[x, y].L) });
                            }
                        }
                    }

                    Frames[f - 1].OriginalBrightness = PixelBrightness.Average(p => p[0]);
                    Frames[f].OriginalBrightness = PixelBrightness.Average(p => p[1]);
                    Frames[f + 1].OriginalBrightness = PixelBrightness.Average(p => p[2]);

                    Frames[f - 1].AlternativeBrightness = Frames[f - 1].OriginalBrightness;
                    Frames[f].AlternativeBrightness = Frames[f].OriginalBrightness;
                    Frames[f + 1].AlternativeBrightness = Frames[f + 1].OriginalBrightness;

                    Frames[f - 1].NewBrightness = Frames[f - 1].OriginalBrightness;
                    Frames[f].NewBrightness = Frames[f].OriginalBrightness;
                    Frames[f + 1].NewBrightness = Frames[f + 1].OriginalBrightness;

                    MainWorker.ReportProgress(0, new ProgressChangeEventArgs(f * 100 / (Frames.Count - 1), ProgressType.CalculateBrightness));
                }
            }
        }
Exemplo n.º 15
0
        public Color GetColor()
        {
            var hexMatch = Regex.Match(Clip.Content, @"#([0-9A-F]{3,8})", RegexOptions.IgnoreCase);

            if (hexMatch.Success)
            {
                var group = hexMatch.Groups[1];

                // Fails for colors codes of length 5 and 7.
                try
                {
                    return((Color)ColorConverter.ConvertFromString("#" + group.Value));
                }
                catch (FormatException)
                {
                    return(new Color());
                }
            }

            var secondaryHexMatch = Regex.Match(Clip.Content, @"^\s*([0-9A-F]{3,8})\s*$", RegexOptions.IgnoreCase);

            if (secondaryHexMatch.Success)
            {
                var group = secondaryHexMatch.Groups[1];

                // Fails for colors codes of length 5 and 7.
                try
                {
                    return((Color)ColorConverter.ConvertFromString("#" + group.Value));
                }
                catch (FormatException)
                {
                    return(new Color());
                }
            }

            var rgbaMatch = Regex.Match(Clip.Content, @"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)", RegexOptions.IgnoreCase);

            if (rgbaMatch.Success)
            {
                byte r = Byte.Parse(rgbaMatch.Groups[1].Value);
                byte g = Byte.Parse(rgbaMatch.Groups[2].Value);
                byte b = Byte.Parse(rgbaMatch.Groups[3].Value);
                byte a = (byte)(255 / Double.Parse(rgbaMatch.Groups[4].Value, NumberStyles.Any, CultureInfo.InvariantCulture));

                return(Color.FromArgb(a, r, g, b));
            }

            var rgbMatch = Regex.Match(Clip.Content, @"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)", RegexOptions.IgnoreCase);

            if (rgbMatch.Success)
            {
                byte r = Byte.Parse(rgbMatch.Groups[1].Value);
                byte g = Byte.Parse(rgbMatch.Groups[2].Value);
                byte b = Byte.Parse(rgbMatch.Groups[3].Value);

                return(Color.FromArgb(255, r, g, b));
            }

            return(new Color());
        }
Exemplo n.º 16
0
        /// <summary>
        /// To plot the bitmap png file for the Hamming Distance of two learnings
        /// </summary>
        /// <param name="twoDimArray">The Hamming Distance array</param>
        /// <param name="width">Width of the array</param>
        /// <param name="height">Height of the array</param>
        /// <param name="filePath">Path where the generated file to be placed</param>
        /// <param name="text">Test to be written on the top left side of the generated file</param>
        public static void DrawBitmapHamming(int[,] twoDimArray, int width, int height, string filePath, string text = null)
        {
            int w = twoDimArray.GetLength(0);
            int h = twoDimArray.GetLength(1);

            var scale = width / w;

            if (scale * w < width)
            {
                scale++;
            }

            Bitmap         myBitmap = new Bitmap(w * scale, h * scale);
            ColorConverter convert  = new ColorConverter();
            int            k        = 0;

            for (int Xcount = 0; Xcount < w; Xcount++)
            {
                for (int Ycount = 0; Ycount < h; Ycount++)
                {
                    for (int padX = 0; padX < scale; padX++)
                    {
                        for (int padY = 0; padY < scale; padY++)
                        {
                            if (twoDimArray[Xcount, Ycount] == 100)
                            {
                                //myBitmap.SetPixel(Xcount, Ycount, System.Drawing.Color.Yellow); // HERE IS YOUR LOGIC
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, Color.White); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 90)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#e6e6e6")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 80)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#d9d9d9")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 70)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#cccccc")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 60)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#bfbfbf")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 50)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#a6a6a6")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 40)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#8c8c8c")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 30)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#737373")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 20)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#595959")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else if (twoDimArray[Xcount, Ycount] >= 10)
                            {
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#333333")); // HERE IS YOUR LOGIC
                                k++;
                            }
                            else
                            {
                                //myBitmap.SetPixel(Xcount, Ycount, System.Drawing.Color.Black); // HERE IS YOUR LOGIC
                                myBitmap.SetPixel(Xcount * scale + padX, Ycount * scale + padY, (Color)convert.ConvertFromString("#000000")); // HERE IS YOUR LOGIC
                                k++;
                            }
                        }
                    }
                }
            }

            Graphics g          = Graphics.FromImage(myBitmap);
            var      fontFamily = new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif);

            g.DrawString(text, new Font(fontFamily, 32), SystemBrushes.Control, new PointF(0, 0));

            myBitmap.Save(filePath, ImageFormat.Png);
        }
        private int[] m_Cb_g_tab;        /* => table for Cb to G conversion */

        /// <summary>
        /// Module initialization routine for output colorspace conversion.
        /// </summary>
        public jpeg_color_deconverter(jpeg_decompress_struct cinfo)
        {
            m_cinfo = cinfo;

            /* Make sure num_components agrees with jpeg_color_space */
            switch (cinfo.m_jpeg_color_space)
            {
                case J_COLOR_SPACE.JCS_GRAYSCALE:
                    if (cinfo.m_num_components != 1)
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_J_COLORSPACE);
                    break;

                case J_COLOR_SPACE.JCS_RGB:
                case J_COLOR_SPACE.JCS_YCbCr:
                    if (cinfo.m_num_components != 3)
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_J_COLORSPACE);
                    break;

                case J_COLOR_SPACE.JCS_CMYK:
                case J_COLOR_SPACE.JCS_YCCK:
                    if (cinfo.m_num_components != 4)
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_J_COLORSPACE);
                    break;

                default:
                    /* JCS_UNKNOWN can be anything */
                    if (cinfo.m_num_components < 1)
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_J_COLORSPACE);
                    break;
            }

            /* Set out_color_components and conversion method based on requested space.
            * Also clear the component_needed flags for any unused components,
            * so that earlier pipeline stages can avoid useless computation.
            */

            switch (cinfo.m_out_color_space)
            {
                case J_COLOR_SPACE.JCS_GRAYSCALE:
                    cinfo.m_out_color_components = 1;
                    if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_GRAYSCALE || cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_YCbCr)
                    {
                        m_converter = ColorConverter.grayscale_converter;
                        /* For color->grayscale conversion, only the Y (0) component is needed */
                        for (int ci = 1; ci < cinfo.m_num_components; ci++)
                            cinfo.Comp_info[ci].component_needed = false;
                    }
                    else
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
                    break;

                case J_COLOR_SPACE.JCS_RGB:
                    cinfo.m_out_color_components = JpegConstants.RGB_PIXELSIZE;
                    if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_YCbCr)
                    {
                        m_converter = ColorConverter.ycc_rgb_converter;
                        build_ycc_rgb_table();
                    }
                    else if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_GRAYSCALE)
                        m_converter = ColorConverter.gray_rgb_converter;
                    else if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_RGB)
                        m_converter = ColorConverter.null_converter;
                    else
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
                    break;

                case J_COLOR_SPACE.JCS_CMYK:
                    cinfo.m_out_color_components = 4;
                    if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_YCCK)
                    {
                        m_converter = ColorConverter.ycck_cmyk_converter;
                        build_ycc_rgb_table();
                    }
                    else if (cinfo.m_jpeg_color_space == J_COLOR_SPACE.JCS_CMYK)
                        m_converter = ColorConverter.null_converter;
                    else
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
                    break;

                default:
                    /* Permit null conversion to same output space */
                    if (cinfo.m_out_color_space == cinfo.m_jpeg_color_space)
                    {
                        cinfo.m_out_color_components = cinfo.m_num_components;
                        m_converter = ColorConverter.null_converter;
                    }
                    else
                    {
                        /* unsupported non-null conversion */
                        cinfo.ERREXIT(J_MESSAGE_CODE.JERR_CONVERSION_NOTIMPL);
                    }
                    break;
            }

            if (cinfo.m_quantize_colors)
                cinfo.m_output_components = 1; /* single colormapped output component */
            else
                cinfo.m_output_components = cinfo.m_out_color_components;
        }
Exemplo n.º 18
0
        public HighlightStyle CreateLabeledZoneStyle(string colorName)
        {
            var color = (Color)ColorConverter.ConvertFromString(colorName);

            return(new HighlightStyle(LEVEL_ONE, color, 0.5, true));
        }
        /// <summary>
        /// This does all of the initialization of the text colors and the background texture-image,
        /// setting the various visual properties based upon which texture was selected.
        /// </summary>
        /// <param name="texture"></param>
        private void InitializeVisualElements()
        {
            #region Based upon the BackgroundTexture, set the background image and background colors.

            JhMessageBoxBackgroundTexture texture = this.Options.BackgroundTexture;
            ImageBrush imageBrush = null;
            string imageFilename = null;
            string sTextBackground1 = null;
            string sTextBackground2 = null;
            string sButtonPanelBackground = null;
            Rect rectViewport = new Rect(0, 0, 40, 40);
            bool isDark = false;
            switch (texture)
            {
                case JhMessageBoxBackgroundTexture.BlueTexture:
                    imageFilename = "bgBlueTexture.png";
                    rectViewport.Width = 593;
                    rectViewport.Height = 463;
                    sTextBackground1 = "#99AECA";
                    sTextBackground2 = "#99AECA";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.BlueMarble:
                    imageFilename = "bgBlueMarble.jpg";
                    rectViewport.Width = rectViewport.Height = 192;
                    //    sTextBackground1 = "#D2DDE3";
                    //    sTextBackground2 = "#D2DDE3";
                    break;
                case JhMessageBoxBackgroundTexture.BrownMarble1:
                    imageFilename = "bgBrownMarble1.gif";
                    rectViewport.Width = 300;
                    rectViewport.Height = 397;
                    //sTextBackground1 = "#F7F7EF";
                    //sTextBackground2 = "#F7F7EF";
                    sButtonPanelBackground = "#FFF0F0F0";
                    break;
                case JhMessageBoxBackgroundTexture.BrownMarble2:
                    imageFilename = "bgBrownMarble2.jpg";
                    rectViewport.Width = rectViewport.Height = 256;
                    sButtonPanelBackground = "#FFF0F0F0";
                    break;
                case JhMessageBoxBackgroundTexture.BrownTexture1:
                    imageFilename = "bgBrownTexture1.jpg";
                    rectViewport.Width = rectViewport.Height = 89;
                    break;
                case JhMessageBoxBackgroundTexture.BrownTexture2:
                    imageFilename = "bgBrownTexture2.gif";
                    rectViewport.Width = 60;
                    rectViewport.Height = 90;
                    sButtonPanelBackground = "#FFF0F0F0";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.BrushedMetal:
                    imageFilename = "bgBrushedMetal.png";
                    rectViewport.Width = 980;
                    rectViewport.Height = 192;
                    //rectBackgroundForButtonPanel.Fill = null;
                    sButtonPanelBackground = "#A5A5A5";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GrayMarble:
                    imageFilename = "bgGrayMarble.jpg";
                    rectViewport.Width = rectViewport.Height = 128;
                    //sTextBackground1 = "#C0BBB8";
                    //txtText.Background = (SolidColorBrush)bc.ConvertFromString("#C0BBB8");
                    sButtonPanelBackground = "#C0BBB8";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GrayTexture1:
                    imageFilename = "TextureR40x40.png";
                    rectViewport.Width = rectViewport.Height = 40;
                    //sTextBackground1 = "#BBBBBB";
                    //sTextBackground2 = "#ABABAB";
                    sButtonPanelBackground = "#ABABAB";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GrayTexture2:
                    imageFilename = "bgGrayTexture2.tif";
                    rectViewport.Width = 429;
                    rectViewport.Height = 440;
                    sTextBackground1 = "#BBBBBB";
                    sTextBackground2 = "#BBBBBB";
                    sButtonPanelBackground = "#D5D5D5";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GreenTexture1:
                    imageFilename = "bgGreenTexture1.gif";
                    rectViewport.Width = 102;
                    rectViewport.Height = 101;
                    sButtonPanelBackground = "#B2B08B";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GreenTexture2:
                    imageFilename = "bgGreenTexture2.gif";
                    rectViewport.Width = 106;
                    rectViewport.Height = 108;
                    sButtonPanelBackground = "#999966";
                    isDark = true;
                    break;
                case JhMessageBoxBackgroundTexture.GreenTexture3:
                    imageFilename = "bgGreenTexture3.jpg";
                    rectViewport.Width = rectViewport.Height = 200;
                    //sTextBackground1 = "#A4B487";
                    //sTextBackground2 = "#A4B487";
                    sButtonPanelBackground = "#8E9E71";
                    isDark = true;
                    break;
                default:
                    break;
            }
            if (imageFilename != null)
            {
                imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri("pack://*****:*****@"pack://application:,,,/JhLib;Component/images/SecurityWarning.png"));
                //                //imgIcon.Source = Microsoft.SDK.Samples.VistaBridge.Library.StockIcons.StockIcons.Shield; // The yellow/blue shield thingy
                //                // This is a gradient that goes from #045042 at the left, to #1C7885 at the right.
                //                sLeftColor = "#045042";
                //                sRightColor = "#1C7885";
                //                txtSummaryText.Foreground = (SolidColorBrush)bc.ConvertFromString("White");
                //            }
                //            else if (this.IconScheme == JhMessageBoxIcon.SecurityShieldGray)
                //            {
                //                imgIcon.Source = new BitmapImage(new Uri(@"pack://application:,,,/JhLib;Component/images/SecurityWarning.png"));
                //                //imgIcon.Source = Microsoft.SDK.Samples.VistaBridge.Library.StockIcons.StockIcons.Shield; // The yellow/blue shield thingy
                //                // This is a gradient that goes from #9D8F85 at the left, to #A49890 at the right.
                //                sLeftColor = "#9D8F85";
                //                sRightColor = "#A49890";
                //                txtSummaryText.Foreground = (SolidColorBrush)bc.ConvertFromString("White");
                //            }
                case JhMessageBoxType.Information:
                    if (_options.IsUsingNewerIcons)
                    {
                        _iconImageName = "InfoBlueDiamond_64x64.png";
                        _iconWidth = _iconHeight = 64;
                        _iconMarginLeft = _iconMarginRight = _iconMarginBottom = 0;
                        //                       minLeftMargin = 60;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "iconInformationStd.png";
                        _iconWidth = _iconHeight = 32;
                        _iconMarginLeft = 4;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //                        minLeftMargin = 37;
                    }
                    _upperRectangleVisibility = Visibility.Collapsed;
                    break;
                case JhMessageBoxType.Question:
                    if (_options.IsUsingNewerIcons)
                    {
                        _iconImageName = "QDiamond_64x64.png";
                        _iconWidth = _iconHeight = 82;
                        _iconMarginLeft = _iconMarginRight = _iconMarginBottom = 0;
                        //minLeftMargin = 77;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "iconQuestionStd.png";
                        _iconWidth = _iconHeight = 32;
                        _iconMarginLeft = 4;
                        _iconMarginRight = _iconMarginBottom = 0;
                        //minLeftMargin = 37;
                    }
                    _upperRectangleVisibility = Visibility.Collapsed;
                    // Use black for question text.
                    _summaryTextForegroundColor = new SolidColorBrush(Colors.Black);
                    break;
                case JhMessageBoxType.UserMistake:
                    if (_options.IsUsingNewerIcons)
                    {
                        //TODO: This image needs to have it's background transparency adjusted.
                        _iconImageName = "Oops.png";
                        _iconWidth = _iconHeight = 65;
                        _iconMarginLeft = _iconMarginRight = _iconMarginBottom = 0;
                        //minLeftMargin = 60;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "iconWarningStd.gif";
                        _iconWidth = 31;
                        _iconHeight = 28;
                        _iconMarginLeft = 4;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 34;
                    }
                    //F6C53A  CF6E17
                    if (texture != JhMessageBoxBackgroundTexture.BrownTexture2 && texture != JhMessageBoxBackgroundTexture.GrayMarble)
                    {
                        if (isDark)
                        {
                            _summaryTextForegroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F6C53A"));
                        }
                        else
                        {
                            _summaryTextForegroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CF6E17"));
                        }
                    }
                    _upperRectangleVisibility = Visibility.Collapsed;
                    break;
                case JhMessageBoxType.Warning:
                    if (_options.IsUsingNewerIcons)
                    {
                        _iconImageName = "warning3_64x64.png";
                        _iconWidth = _iconHeight = 64;
                        _iconMarginLeft = 3;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 66;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "iconWarningStd.gif";
                        _iconWidth = 31;
                        _iconHeight = 28;
                        _iconMarginLeft = 4;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 34;
                    }
                    _upperRectangleVisibility = Visibility.Collapsed;
                    // Push it to pure blue for these two rather difficult backgrounds..
                    if (texture == JhMessageBoxBackgroundTexture.BrushedMetal || texture == JhMessageBoxBackgroundTexture.GreenTexture3)
                    {
                        //_summaryTextForegroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0000FF"));
                        _summaryTextForegroundColor = new SolidColorBrush(Colors.Blue);
                    }
                    break;
                case JhMessageBoxType.Error:
                    if (_options.IsUsingNewerIcons)
                    {
                        _iconImageName = "errorDiamond_48x48.png";
                        _iconWidth = _iconHeight = 48;
                        _iconMarginLeft = 1;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 48;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "RedShield.png";
                        _iconWidth = 26;
                        _iconHeight = 32;
                        // This is a red gradient that goes from #AC0100 at the left, to #E30100 at the right.
                        sLeftColor = "#AC0100";
                        sRightColor = "#EB0100"; // "#E30100" is what I measured on the native messagebox color.
                        _iconMarginLeft = 3;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                    }
                    // If there is no texture, then make the summary-text white to contrast against the red gradiant..
                    if (imageFilename == null)
                    {
                        _summaryTextForegroundColor = new SolidColorBrush(Colors.White);
                    }
                    else
                    {
                        if (texture == JhMessageBoxBackgroundTexture.BrushedMetal)
                        {
                            _summaryTextForegroundColor = new SolidColorBrush(Colors.White);
                        }
                        else
                        {
                            _summaryTextForegroundColor = new SolidColorBrush(Colors.Red);
                        }
                    }
                    break;
                case JhMessageBoxType.Stop:
                    if (_options.IsUsingNewerIcons)
                    {
                        _iconImageName = "hand64x64.png";
                        _iconWidth = _iconHeight = 64;
                        _iconMarginLeft = 0;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 60;
                    }
                    else // use the old icon
                    {
                        _iconImageName = "iconErrorStd.gif";
                        _iconWidth = _iconHeight = 32;
                        _iconMarginLeft = 5;
                        _iconMarginRight = 0;
                        _iconMarginBottom = 0;
                        //minLeftMargin = 40;
                    }
                    // If there is no texture, then make the summary-text white to contrast against the red gradiant..
                    if (imageFilename == null)
                    {
                        _summaryTextForegroundColor = new SolidColorBrush(Colors.White);
                    }
                    else
                    {
                        if (texture == JhMessageBoxBackgroundTexture.BrushedMetal)
                        {
                            _summaryTextForegroundColor = new SolidColorBrush(Colors.White);
                        }
                        else
                        {
                            _summaryTextForegroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3E29"));
                        }
                    }
                    break;
                default:  // no particular message-type
                    _iconWidth = 0;
                    _iconMarginLeft = _iconMarginTop = _iconMarginRight = _iconMarginBottom = 0;
                    _upperRectangleVisibility = Visibility.Collapsed;
                    break;
            } // end switch.

            //TODO: This is just tinkeriing..
            if (texture == JhMessageBoxBackgroundTexture.GreenTexture3)
            {
                imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/JhLib;Component/Images/" + imageFilename));
                imageBrush.ViewportUnits = BrushMappingMode.Absolute;
                imageBrush.Stretch = Stretch.None;
                imageBrush.Viewport = rectViewport;
                imageBrush.TileMode = TileMode.Tile;
                _buttonPanelBackground = new SolidColorBrush(Colors.Transparent);
                _summaryTextBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8E9E71"));
                _detailTextBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8E9E71"));
            }
            // Determine whether the icon extends into the bottom, detail-text region..
            bool isIconExtendingIntoDetailArea = false;
            if (_iconHeight > 38)
            {
                if (_iconHeight <= 48)
                {
                    _iconMarginTop = 5;
                }
                else
                {
                    _iconMarginTop = 0;
                }
                isIconExtendingIntoDetailArea = true;
            }
            else
            {
                _iconMarginLeft = 9;
                _iconMarginTop = 36 - _iconHeight;
            }
            if (_iconWidth > 32)
            {
                minLeftMargin = _iconWidth + 2;
            }
            else if (_iconWidth == 0)
            {
                minLeftMargin = 0;
            }
            else
            {
                minLeftMargin = _iconWidth - 4;
            }
            //            Console.WriteLine("minLeftMargin = " + minLeftMargin);

            #endregion Colors and Icon

            #region Set the color-gradiant rectangle

            // If there is no background-texture, then - if we have gradient colors defined (for that upper part)..
            if (imageFilename != null)
            {
                _upperRectangleVisibility = Visibility.Collapsed;
            }
            else if (sLeftColor != null && sRightColor != null)
            {
                // There is a left and right color defined, thus there is a gradiant to show.
            #if SILVERLIGHT
                // Silverlight does not have it's own ColorConverter, so I had to provide one.
                var cc = new ColorConverter();
                colorLeft = (Color)cc.Convert(sLeftColor, typeof(Color), null, null);
                colorRight = (Color)cc.Convert(sRightColor, typeof(Color), null, null);
            #else
                colorLeft = (Color)ColorConverter.ConvertFromString(sLeftColor);
                colorRight = (Color)ColorConverter.ConvertFromString(sRightColor);
            #endif
                _gradiantLeftColor = colorLeft;
                _gradiantRightColor = colorRight;
                _upperRectangleVisibility = Visibility.Visible;
            }
            #endregion Set the color-gradiant rectangle

            #region Position the text

            // 77 is a reasonable number of characters if you only want this to shift to the left after two lines of text are filled.
            if (SummaryText.Length > 87)
            {
                _summaryTextHorizontalAlignment = HorizontalAlignment.Left;
                _summaryTextMargin = new Thickness(_iconMarginLeft + _iconWidth, 0, 0, 0);
            }
            else if (SummaryText.Length > 34)
            {
                // Shift it over partway, so it is still at least somewhat centered.
                //_summaryTextMargin = new Thickness(minLeftMargin + 20, 0, 0, 0);
                _summaryTextHorizontalAlignment = HorizontalAlignment.Center;
                _summaryTextMargin = new Thickness(_iconMarginLeft + _iconWidth, 0, 0, 0);
            }
            else
            {
                _summaryTextHorizontalAlignment = HorizontalAlignment.Center;
                if (DetailText.Length < 40)
                {
                    _detailTextMarginLeft = 0;
                    _summaryTextMargin = new Thickness(0, 0, 0, 0);
                }
                else
                {
                    _summaryTextMargin = new Thickness(_iconMarginLeft + _iconWidth, 0, 0, 0);
                }
            }

            _detailTextMarginLeft = minLeftMargin;
            // If there is no detail-text,
            if (String.IsNullOrWhiteSpace(this.DetailText))
            {
                // then let the summary-text span the entire height that is available for text.
                SummaryTextRowSpan = 2;
                _upperRectangleRowSpan = 2;
            }
            else // there is some detail-text
            {
                SummaryTextRowSpan = 1;
                _upperRectangleRowSpan = 1;
                // If the detail-text is too long to fit on one line, expand it to the left so that it fills the width of the entire message-box.
                if (isIconExtendingIntoDetailArea)
                {
                    if (SummaryText.Length < 34 && DetailText.Length < 40)
                    {
                        _detailTextMarginLeft = 0;
                    }
                    else
                    {
                        _detailTextMarginLeft = minLeftMargin;
                    }
                }
                else // the icon does not extend into the detail-text area
                {
                    if (DetailText.Length > 61)
                    {
                        _detailTextMarginLeft = 0;
                    }
                }
                // If the detail-text is long enough such that to center it no longer makes sense, set it to left-justify.
                if (DetailText.Length > 100)
                {
                    _detailTextHorizontalAlignment = HorizontalAlignment.Left;
                }

                if (DetailText.Length > 87 || SummaryText.Length > 60)
                {
                    _windowHeight = 192;
                }
                // If the (main) text is long enough to warrant more than one line,
                // make the text area left-justified instead of centered.
                if (DetailText.Length > 122)
                {
                    _detailTextVerticalAlignment = VerticalAlignment.Top;
                    _windowHeight = 220.0;
                }
            }
            //            Console.WriteLine("_detailTextHorizontalAlignment = " + _detailTextHorizontalAlignment);
            //            Console.WriteLine("_detailTextMarginLeft = " + _detailTextMarginLeft);
            #endregion Position the text

            #region Size and position the buttons

            _buttonCount = 0;
            if ((Options.ButtonFlags & JhMessageBoxButtons.Cancel) == JhMessageBoxButtons.Cancel)
            {
                _isCancelButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.Close) == JhMessageBoxButtons.Close)
            {
                _isCloseButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.Ignore) == JhMessageBoxButtons.Ignore)
            {
                _isIgnoreButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.Ok) == JhMessageBoxButtons.Ok)
            {
                _isOkButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.Retry) == JhMessageBoxButtons.Retry)
            {
                _isRetryButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.Yes) == JhMessageBoxButtons.Yes)
            {
                _isYesButtonVisible = true;
                _buttonCount++;
            }
            if ((Options.ButtonFlags & JhMessageBoxButtons.No) == JhMessageBoxButtons.No)
            {
                _isNoButtonVisible = true;
                _buttonCount++;
            }

            // Button width by default had been 55, which works for 6 buttons.
            // If we only have a small subset of the available buttons showing, then give them a bit more breathing room..
            int n = _buttonCount;
            if (n < 5)
            {
                _buttonWidth = 80;
            }
            else if (n < 6)
            {
                _buttonWidth = 65;
            }
            else if (n < 7)
            {
                _buttonWidth = 57;
            }
            else
            {
                _buttonWidth = 49;
            }

            if (n < 4)
            {
                _buttonMargin = new Thickness(9.0, 2.0, 9.0, 2.0);
            }
            else if (n < 5)
            {
                _buttonMargin = new Thickness(4.0, 2.0, 5.0, 2.0);
            }
            else if (n < 6)
            {
                _buttonMargin = new Thickness(3.0, 2.0, 3.0, 2.0);
            }
            else if (n < 7)
            {
                _buttonMargin = new Thickness(2.0, 2.0, 2.0, 2.0);
            }
            else
            {
                _buttonMargin = new Thickness(1.5, 2.0, 1.5, 2.0);
            }
            #endregion Size and position the buttons

            _isInitialized = true;
        }
Exemplo n.º 20
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of banner information from the Banners
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the DotNetNuke.BannerDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //exit without displaying banners to crawlers
            if (Request.Browser.Crawler)
            {
                return;
            }
            try
            {
                int    intPortalId     = 0;
                int    intBannerTypeId = 0;
                string strBannerGroup;
                int    intBanners = 0;

                //banner parameters
                switch (Convert.ToString(Settings["bannersource"]))
                {
                case "L":     //local
                case "":
                    intPortalId = PortalId;
                    break;

                case "G":     //global
                    intPortalId = Null.NullInteger;
                    break;
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannertype"])))
                {
                    intBannerTypeId = Int32.Parse(Convert.ToString(Settings["bannertype"]));
                }
                strBannerGroup = Convert.ToString(Settings["bannergroup"]);
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannercount"])))
                {
                    intBanners = Int32.Parse(Convert.ToString(Settings["bannercount"]));
                }
                if (!String.IsNullOrEmpty(Convert.ToString(Settings["padding"])))
                {
                    lstBanners.CellPadding = Int32.Parse(Convert.ToString(Settings["padding"]));
                }

                //load banners
                if (intBanners != 0)
                {
                    var objBanners = new BannerController();
                    lstBanners.DataSource = objBanners.LoadBanners(intPortalId, ModuleId, intBannerTypeId, strBannerGroup, intBanners);
                    lstBanners.DataBind();
                }

                //set banner display characteristics
                if (lstBanners.Items.Count != 0)
                {
                    //container attributes
                    lstBanners.RepeatLayout = RepeatLayout.Table;
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["orientation"])))
                    {
                        switch (Convert.ToString(Settings["orientation"]))
                        {
                        case "H":
                            lstBanners.RepeatDirection = RepeatDirection.Horizontal;
                            break;

                        case "V":
                            lstBanners.RepeatDirection = RepeatDirection.Vertical;
                            break;
                        }
                    }
                    else
                    {
                        lstBanners.RepeatDirection = RepeatDirection.Vertical;
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["border"])))
                    {
                        lstBanners.ItemStyle.BorderWidth = Unit.Parse(Convert.ToString(Settings["border"]) + "px");
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["bordercolor"])))
                    {
                        var objColorConverter = new ColorConverter();
                        lstBanners.ItemStyle.BorderColor = (Color)objColorConverter.ConvertFrom(Convert.ToString(Settings["bordercolor"]));
                    }

                    //item attributes
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["rowheight"])))
                    {
                        lstBanners.ItemStyle.Height = Unit.Parse(Convert.ToString(Settings["rowheight"]) + "px");
                    }
                    if (!String.IsNullOrEmpty(Convert.ToString(Settings["colwidth"])))
                    {
                        lstBanners.ItemStyle.Width = Unit.Parse(Convert.ToString(Settings["colwidth"]) + "px");
                    }
                }
                else
                {
                    lstBanners.Visible = false;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
    public void sendEmail()
    {
        Whitfieldcore wCore = new Whitfieldcore();
        whitfield_reports _wRep = new whitfield_reports();
        MailMessage message = new MailMessage();

        message.To.Add(System.Configuration.ConfigurationManager.AppSettings["devEmail"]);

        //Here is where we add the receipients.
        using (DataSet ds = wCore.GetRightDistributionList(Convert.ToInt32(ViewState["twc_project_number"].ToString())) )  //HHS Uncomment this portion when there is an email list.
        {
            DataTable dtUsr = ds.Tables[0];
            if (dtUsr.Rows.Count > 0)
            {
                foreach (DataRow dRow in dtUsr.Rows)
                {
                    string _email = dRow["Email"] == DBNull.Value ? "" : dRow["Email"].ToString();
                    message.To.Add(_email);
                }
            }
        }

        message.To.Add(System.Configuration.ConfigurationManager.AppSettings["AdminEmail"].ToString());
        //This is commented by Harish on Friday, January 27th with the request of Jammie.
        //message.To.Add(System.Configuration.ConfigurationManager.AppSettings["PMEmail"].ToString());

        message.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["DFR_fromEmail"]);
        message.Subject = txtReportDate.Text.Trim() + "  Daily Field Report:" + lblPrjHeader.Text.Trim();
        message.IsBodyHtml = true;

        StringBuilder sb = new StringBuilder();
        sb.Append("<html><head></head>");
        sb.Append("<body>");
        //Header
        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD><IMG height='80' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/TWC%20Primary%20Logo1.JPG' border='0'></TD>");
        sb.Append("<TD class='form1' vAlign='bottom' align='right' width='100%'><b>The Whitfield Corporation, Inc.,<br>");
        sb.Append("P.O. Box 0385<br>");
        sb.Append("Fulton, MD 20759<br>");
        sb.Append("(301)-483-0791<br>");
        sb.Append("(301)-483-0792</b><br>");
        sb.Append("<IMG height='9' alt='' src='http://www.whitfield-co.com/whitfield-co/assets/img/images.gif' width='1'>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        //EmployeeHours
        System.Drawing.ColorConverter colConvert = new ColorConverter();
        DataGrid dgWorkOrders = new DataGrid();
        dgWorkOrders.Font.Size = 9;
        dgWorkOrders.CssClass = "data";

        dgWorkOrders.HeaderStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#60829F");
        dgWorkOrders.HeaderStyle.CssClass = "subnav";
        dgWorkOrders.HeaderStyle.Font.Bold = true;
        dgWorkOrders.ItemStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#EAEFF3");
        dgWorkOrders.FooterStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#D9D9D9");

        dgWorkOrders.DataSource = _wRep.GetReportActivityForProjectMail(_wRep.GetReportNumber(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text.Trim()), Convert.ToInt32(ViewState["twc_project_number"].ToString()));
        dgWorkOrders.DataBind();

        StringBuilder SBEmployeeHours = new StringBuilder();
        StringWriter SWEmployeeHours = new StringWriter(SBEmployeeHours);
        HtmlTextWriter htmlTWEmployeeHours = new HtmlTextWriter(SWEmployeeHours);
        dgWorkOrders.RenderControl(htmlTWEmployeeHours);
        string EmployeeHoursString = SBEmployeeHours.ToString();
        sb.Append("<br><B>Work Executed for Today:</b><br>" + EmployeeHoursString);

        //Daily Work Performed Notes/Comments
        String StrRptNotes = "";

        if (txtRptNotes.Text == "")
        {
            StrRptNotes = "None.";
        }
        else
        {
            StrRptNotes = txtRptNotes.Text.Trim();
        }
        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD>");
        sb.Append("<br><b>Daily Work Performed Notes/Comments:</b>" + StrRptNotes + "<br>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        //Significant Issues/Impediments Notes/Comments:
        String StrRptIssues = "";

        if (txtRptIssues.Text == "")
        {
            StrRptIssues = "None.";
        }
        else
        {
            StrRptIssues = txtRptIssues.Text.Trim();
        }

        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD>");
        sb.Append("<br><b>Significant Issues/Impediments Notes/Comments:</b>" + StrRptIssues + "<br>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        //Change Order Work Notes/Comments

        String StrRptChangeOrderNotes = "";
        if (txtRptChangeOrderNotes.Text == "")
        {
            StrRptChangeOrderNotes = "None.";
        }
        else
        {
            StrRptChangeOrderNotes = txtRptChangeOrderNotes.Text.Trim();
        }

        sb.Append("<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'><TR>");
        sb.Append("<TD>");
        sb.Append("<br><b>Change Order Work Notes/Comments:</b>" + StrRptChangeOrderNotes + "<br>");
        sb.Append("</TD>");
        sb.Append("</TR></TABLE>");

        //Man Power Detail
        DataGrid dg = new DataGrid();
        dg.Font.Size = 9;
        dg.CssClass = "data";

        dg.HeaderStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#60829F");
        dg.HeaderStyle.CssClass = "subnav";
        dg.HeaderStyle.Font.Bold = true;
        dg.ItemStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#EAEFF3");
        dg.FooterStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#D9D9D9");

        dg.DataSource = _wRep.GetManPowerEntriesMail(_wRep.GetReportNumber(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text.Trim()));
        dg.DataBind();
        StringBuilder SBActivity = new StringBuilder();
        StringWriter SWActivity = new StringWriter(SBActivity);
        HtmlTextWriter htmlTWActivity = new HtmlTextWriter(SWActivity);
        dg.RenderControl(htmlTWActivity);
        string ActivityString = SBActivity.ToString();

        ////EmployeeHours
        //DataGrid dgWorkOrders = new DataGrid();
        //dgWorkOrders.Font.Size = 9;
        //dgWorkOrders.CssClass = "data";

        //dgWorkOrders.HeaderStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#60829F");
        //dgWorkOrders.HeaderStyle.CssClass = "subnav";
        //dgWorkOrders.HeaderStyle.Font.Bold = true;
        //dgWorkOrders.ItemStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#EAEFF3");
        //dgWorkOrders.FooterStyle.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("#D9D9D9");

        //dgWorkOrders.DataSource = _wRep.GetReportActivityForProjectMail(_wRep.GetReportNumber(Convert.ToInt32(ViewState["twc_project_number"].ToString()), txtReportDate.Text.Trim()), Convert.ToInt32(ViewState["twc_project_number"].ToString()));
        //dgWorkOrders.DataBind();

        //StringBuilder SBEmployeeHours = new StringBuilder();
        //StringWriter SWEmployeeHours = new StringWriter(SBEmployeeHours);
        //HtmlTextWriter htmlTWEmployeeHours = new HtmlTextWriter(SWEmployeeHours);
        //dgWorkOrders.RenderControl(htmlTWEmployeeHours);
        //string EmployeeHoursString = SBEmployeeHours.ToString();

        sb.Append("<br><b>Man Power Detail:</b><br>" + ActivityString);
        sb.Append("</body></html>");
        message.Body = sb.ToString();
        SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["smtp"]);
        smtp.Send(message);
    }
Exemplo n.º 22
0
        // Return "Errors" label to regular color.
        private void ErrorsBox_Opened(object sender, System.EventArgs e)
        {
            Color color = (Color)ColorConverter.ConvertFromString("#FFE5D5D5");

            ErrorsLabel.Foreground = new SolidColorBrush(color);
        }
 private void BCA_Button_Loaded(object sender, RoutedEventArgs e)
 {
     text.InitLabel(ButtonText, Colors.White, (Color)ColorConverter.ConvertFromString("#FF14126E"), 22);
 }
Exemplo n.º 24
0
 public static System.Windows.Media.Color GetColorFromHexValue(string aiHexValue)
 {
     return((System.Windows.Media.Color)ColorConverter.ConvertFromString(aiHexValue));
 }
        internal void RepaintRadioStatus()
        {
            SetupEncryption();

            var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;

            if ((dcsPlayerRadioInfo == null) || !dcsPlayerRadioInfo.IsCurrent())
            {
                RadioActive.Fill    = new SolidColorBrush(Colors.Red);
                RadioLabel.Text     = "No Radio";
                RadioFrequency.Text = "Unknown";

                RadioVolume.IsEnabled = false;
                RadioVolume.Width     = 115;

                TunedClients.Visibility = Visibility.Hidden;

                ToggleButtons(false);

                //reset dragging just incase
                _dragging = false;
            }
            else
            {
                if (RadioId == dcsPlayerRadioInfo.selected)
                {
                    var transmitting = UdpVoiceHandler.RadioSendingState;

                    if (transmitting.IsSending && (transmitting.SendingOn == RadioId))
                    {
                        RadioActive.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#96FF6D"));
                    }
                    else
                    {
                        RadioActive.Fill = new SolidColorBrush(Colors.Green);
                    }
                }
                else
                {
                    RadioActive.Fill = new SolidColorBrush(Colors.Orange);
                }

                var currentRadio = dcsPlayerRadioInfo.radios[RadioId];

                if (currentRadio.modulation == RadioInformation.Modulation.DISABLED) // disabled
                {
                    RadioActive.Fill    = new SolidColorBrush(Colors.Red);
                    RadioLabel.Text     = "No Radio";
                    RadioFrequency.Text = "Unknown";

                    RadioVolume.IsEnabled = false;

                    ToggleButtons(false);
                    return;
                }
                if (currentRadio.modulation == RadioInformation.Modulation.INTERCOM) //intercom
                {
                    RadioFrequency.Text = "INTERCOM";
                }
                else
                {
                    RadioFrequency.Text =
                        (currentRadio.freq / MHz).ToString("0.000",
                                                           CultureInfo.InvariantCulture) + //make nuber UK / US style with decimals not commas!
                        (currentRadio.modulation == 0 ? "AM" : "FM");
                    if (currentRadio.secFreq > 100)
                    {
                        RadioFrequency.Text += " G";
                    }

                    if (currentRadio.channel >= 0)
                    {
                        RadioFrequency.Text += " C" + currentRadio.channel;
                    }

                    if (currentRadio.enc && (currentRadio.encKey > 0))
                    {
                        RadioFrequency.Text += " E" + currentRadio.encKey; // ENCRYPTED
                    }

                    int count = _connectClientsSingleton.ClientsOnFreq(currentRadio.freq, currentRadio.modulation);

                    if (count > 0)
                    {
                        TunedClients.Text       = "👤" + count;
                        RadioVolume.Width       = 105;
                        TunedClients.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        TunedClients.Visibility = Visibility.Hidden;
                        RadioVolume.Width       = 115;
                    }
                }

                RadioLabel.Text = dcsPlayerRadioInfo.radios[RadioId].name;

                if (currentRadio.volMode == RadioInformation.VolumeMode.OVERLAY)
                {
                    RadioVolume.IsEnabled = true;

                    //reset dragging just incase
                    //    _dragging = false;
                }
                else
                {
                    RadioVolume.IsEnabled = false;

                    //reset dragging just incase
                    //  _dragging = false;
                }

                ToggleButtons(currentRadio.freqMode == RadioInformation.FreqMode.OVERLAY);

                if (_dragging == false)
                {
                    RadioVolume.Value = currentRadio.volume * 100.0;
                }
            }
        }
Exemplo n.º 26
0
 public void SetConnectionStatus(AppSettings.ConnectionStatusValue status)
 {
     this.CallUI(new ThreadStart(delegate
     {
         this.connectionStatus = status;
         BindConnectionStatusBackground.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(status.StatusColor));
         BindConnectionStatusText.Content          = status.StatusText.ToUpper();
     }));
 }
Exemplo n.º 27
0
 private static Color GetColor(string hex)
 {
     return((Color)ColorConverter.ConvertFromString(hex));
 }
Exemplo n.º 28
0
 public static Color ColorFromString(string text) => (Color)ColorConverter.ConvertFromString(text);
Exemplo n.º 29
0
        private void ApplyProperties(object control, XmlNode node)
        {
            XmlNodeList props = node.SelectNodes("./property");

            foreach (XmlNode prop in props)
            {
                string propName = prop.Attributes["name"].Value;
                string propType = prop.Attributes["type"].Value;
                if (propName.ToLower() == "zorder")
                {
                    int zorder = (int)new Int32Converter().ConvertFromString(prop.Attributes["value"].Value);
                    (control as Control).Parent.Controls.SetChildIndex(control as Control, zorder);
                }
                else
                {
                    PropertyInfo propInfo = control.GetType().GetProperty(propName, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase, null, null, new Type[0], null);
                    if (propInfo != null)
                    {
                        object value = null;
                        switch (propType.ToLower())
                        {
                        case "binding":
                        {
                            if (control is Control cont)
                            {
                                cont.DataBindings.Add(propName, this, prop.Attributes["value"].Value);
                            }
                            break;
                        }

                        case "colour":
                        case "color":
                        {
                            value = new ColorConverter().ConvertFromInvariantString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "font":
                        {
                            value = new FontConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "string":
                        {
                            value = new StringConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "boolean":
                        case "bool":
                        {
                            value = new BooleanConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "location":
                        case "point":
                        {
                            var p = (Point) new PointConverter().ConvertFromString(prop.Attributes["value"].Value);
                            if (p.X < 0)
                            {
                                p.X = this.DisplayRectangle.Right + p.X;
                            }
                            if (p.Y < 0)
                            {
                                p.Y = this.DisplayRectangle.Bottom + p.Y;
                            }
                            value = p;
                            break;
                        }

                        case "size":
                        {
                            var s = (Size) new SizeConverter().ConvertFromString(prop.Attributes["value"].Value);
                            if (s.Width < 0)
                            {
                                s.Width = this.DisplayRectangle.Width + s.Width;
                            }
                            if (s.Height < 0)
                            {
                                s.Height = this.DisplayRectangle.Height + s.Height;
                            }
                            value = s;
                            break;
                        }

                        case "integer":
                        case "int32":
                        case "int":
                        {
                            value = new Int32Converter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "rect":
                        case "rectangle":
                        {
                            value = new RectangleConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "margin":
                        case "padding":
                        {
                            value = new PaddingConverter().ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "dock":
                        {
                            value = new EnumConverter(typeof(DockStyle)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "anchor":
                        {
                            value = new EnumConverter(typeof(AnchorStyles)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "pictureboxsizemode":
                        case "sizemode":
                        {
                            value = new EnumConverter(typeof(PictureBoxSizeMode)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "contentalignment":
                        case "textalign":
                        case "align":
                        case "alignment":
                        {
                            value = new EnumConverter(typeof(ContentAlignment)).ConvertFromString(prop.Attributes["value"].Value);
                            break;
                        }

                        case "image":
                        {
                            string filename = prop.Attributes["value"].Value;
                            filename = filename.Replace("{skindir}", System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Skins"));
                            value    = Image.FromFile(filename);
                            break;
                        }

                        case "object":
                        {
                            // that means this property has properties of its own, so....
                            object propValue = propInfo.GetValue(control, null);
                            if (propValue != null)
                            {
                                ApplyProperties(propValue, prop);
                            }
                            break;
                        }
                        }
                        if (value != null)
                        {
                            propInfo.SetValue(control, value, null);
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
 private void SelectColorCommandExecute(object sender, ExecutedRoutedEventArgs e)
 {
     CurrentColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(e.Parameter.ToString()));
 }
Exemplo n.º 31
0
        /// <summary>
        //  Try to parse a color given in different flavours (hex, rgb, name)
        /// </summary>
        public static bool TryParseColor(string strVal, double alpha, out Color color)
        {
            // 1: color is specified in rgb values
            if (strVal.StartsWith("rgb(", StringComparison.OrdinalIgnoreCase))
            {
                var      str   = strVal.Substring(4, strVal.Length - 5);
                string[] parts = str.Split(',');

                if (parts.Length != 3)
                {
                    color = Colors.Black;
                    return(false);
                }

                try
                {
                    string redStr   = parts[0].Trim();
                    string greenStr = parts[1].Trim();
                    string blueStr  = parts[2].Trim();
                    byte   red;
                    byte   green;
                    byte   blue;

                    if (string.IsNullOrWhiteSpace(redStr) ||
                        string.IsNullOrWhiteSpace(greenStr) ||
                        string.IsNullOrWhiteSpace(blueStr))
                    {
                        red   = 0;
                        green = 0;
                        blue  = 0;
                    }
                    else
                    {
                        red   = (byte)ParseColorValue(redStr);
                        green = (byte)ParseColorValue(greenStr);
                        blue  = (byte)ParseColorValue(blueStr);
                    }

                    color = Color.FromArgb((byte)(alpha * 255), red, green, blue);
                    return(true);
                }
                catch
                {
                }

                color = Colors.Black;
                return(false);
            }

            // 2: color is specified in rgba values
            if (strVal.StartsWith("rgba(", StringComparison.OrdinalIgnoreCase))
            {
                var      str   = strVal.Substring(5, strVal.Length - 6);
                string[] parts = str.Split(',');

                if (parts.Length != 4)
                {
                    color = Colors.Black;
                    return(false);
                }

                try
                {
                    string redStr   = parts[0].Trim();
                    string greenStr = parts[1].Trim();
                    string blueStr  = parts[2].Trim();
                    string alphaStr = parts[3].Trim();
                    byte   red;
                    byte   green;
                    byte   blue;
                    double alphaD;

                    if (string.IsNullOrWhiteSpace(alphaStr) ||
                        string.IsNullOrWhiteSpace(redStr) ||
                        string.IsNullOrWhiteSpace(greenStr) ||
                        string.IsNullOrWhiteSpace(blueStr))
                    {
                        alphaD = 1;
                        red    = 0;
                        green  = 0;
                        blue   = 0;
                    }
                    else
                    {
                        red    = (byte)ParseColorValue(redStr);
                        green  = (byte)ParseColorValue(greenStr);
                        blue   = (byte)ParseColorValue(blueStr);
                        alphaD = DoubleWithUnitParser.Parse(alphaStr);
                    }

                    color = Color.FromArgb((byte)(alpha * alphaD * 255), red, green, blue);
                    return(true);
                }
                catch
                {
                }

                color = Colors.Black;
                return(false);
            }

            // 3: color is specified in hsl values
            if (strVal.StartsWith("hsl(", StringComparison.OrdinalIgnoreCase))
            {
                var      str   = strVal.Substring(4, strVal.Length - 5);
                string[] parts = str.Split(',');

                if (parts.Length != 3)
                {
                    color = Colors.Black;
                    return(false);
                }
                try
                {
                    string hueStr        = parts[0].Trim();
                    string saturationStr = parts[1].Trim();
                    string luminosityStr = parts[2].Trim();

                    if (string.IsNullOrWhiteSpace(hueStr) ||
                        string.IsNullOrWhiteSpace(saturationStr) ||
                        string.IsNullOrWhiteSpace(luminosityStr))
                    {
                        color = Colors.Black;
                        return(true);
                    }
                    else
                    {
                        var hue        = DoubleWithUnitParser.Parse(hueStr);
                        var saturation = DoubleWithUnitParser.Parse(saturationStr);
                        var luminosity = DoubleWithUnitParser.Parse(luminosityStr);

                        color = ColorModelConverter.ConvertHlsToRgb(alpha, hue, saturation, luminosity);
                        return(true);
                    }
                }
                catch
                {
                }

                color = Colors.Black;
                return(false);
            }

            // 4: color is either given as name or hex values
            try
            {
                var color2 = (Color)ColorConverter.ConvertFromString(strVal);
                color = Color.FromArgb((byte)(alpha * 255), color2.R, color2.G, color2.B);
                return(true);
            }
            catch
            {
            }

            color = Colors.Black;
            return(false);
        }
    protected void grdvwRequest_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            System.Drawing.ColorConverter colConvert = new ColorConverter();
            BLLCollection<ColorScheme_mst> colColor = new BLLCollection<ColorScheme_mst>();
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                #region Autogenerate Serial number
                Label lblSerial = (Label)e.Row.FindControl("lblSerial");
                lblSerial.Text = i.ToString();
                i++;
                #endregion

                int TotalTimeSpentonCall;
                int TotalResolutionTime;

                int varIncidentid = Convert.ToInt32(((Label)e.Row.FindControl("incidentid")).Text.ToString());
                string varCreateDatetime = e.Row.Cells[9].Text;
                string varStatusOpen = Resources.MessageResource.strStatusOpen.ToString();
                string varStatusClose = Resources.MessageResource.strStatusClose.ToString();
                string varStatusOnHold = Resources.MessageResource.strStatusOnHold.ToString();

                string varStatusResolved = Resources.MessageResource.strStatusResolved.ToString();

                #region Bind Data Row at Run time with requesterid to Requester name
                int requesterid = Convert.ToInt32(e.Row.Cells[3].Text);
                //objUser = objUser.Get_By_id(requesterid);
                objContactmst = objContactmst.Get_By_id(requesterid);
                //if (objUser.Userid != 0)
                //{
                //    e.Row.Cells[3].Text = objUser.Username.ToString();
                //    //e.Row.Cells[3].Text = objContactmst.Firstname.ToString();
                //}
                //else { e.Row.Cells[3].Text = ""; }
                //if (objUser.Userid != 0)
                //{
                //e.Row.Cells[3].Text = objUser.Username.ToString();
                if (objContactmst.Firstname != null)
                {
                    e.Row.Cells[3].Text = objContactmst.Firstname.ToString();
                }
                // }else { e.Row.Cells[3].Text = ""; }
                #endregion

                #region Bind Datarow at Run Time with Createdbyid to Created by name
                int createdbyid = Convert.ToInt32(e.Row.Cells[4].Text);
                objUser = objUser.Get_By_id(createdbyid);
                if (objUser.Userid != 0)
                {
                    e.Row.Cells[4].Text = objUser.Username.ToString();
                }
                else { e.Row.Cells[4].Text = ""; }
                #endregion

                #region Bind Datarow at Run Time with technicianid to technician name
                int technicianid = Convert.ToInt32(e.Row.Cells[5].Text);
                objUser = objUser.Get_By_id(technicianid);
                if (objUser.Userid != 0)
                {
                    e.Row.Cells[5].Text = objUser.Username.ToString();
                }
                else { e.Row.Cells[5].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Statusid to Status
                int statusid = Convert.ToInt32(e.Row.Cells[6].Text);
                objStatus = objStatus.Get_By_id(statusid);
                if (objStatus.Statusid != 0)
                {

                    e.Row.Cells[6].Text = objStatus.Statusname.ToString();

                }
                else { e.Row.Cells[6].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Priorityid to Priority
                int priorityid = Convert.ToInt32(e.Row.Cells[7].Text);
                objPriority = objPriority.Get_By_id(priorityid);
                if (objPriority.Priorityid != 0)
                { e.Row.Cells[7].Text = objPriority.Name.ToString(); }
                else { e.Row.Cells[7].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Siteid to Site
                int siteid = Convert.ToInt32(e.Row.Cells[8].Text);
                objSite = objSite.Get_By_id(siteid);
                if (objSite.Siteid != 0)
                {
                    string custSiteName;
                    int custid = 0;
                    colCustToSite = objCustToSite.Get_All_By_siteid(objSite.Siteid);
                    foreach (CustomerToSiteMapping objCuToSite in colCustToSite)
                    {
                        custid = objCuToSite.Custid;

                    }
                    objCustomer = objCustomer.Get_By_id(custid);

                    e.Row.Cells[8].Text = objCustomer.Customer_name + "/" + objSite.Sitename.ToString();

                }
                else { e.Row.Cells[8].Text = ""; }
                #endregion

                #region Apply Color Coding to Open Calls,According to define SLA
                if (varStatusOpen.ToLower() == objStatus.Statusname.ToString().ToLower())
                {

                    Incident_mst obj = new Incident_mst();
                    obj = obj.Get_By_id(varIncidentid);
                    if (obj.Incidentid != 0)
                    {
                        if (obj.Slaid != 0)
                        {
                            #region Declare local variables,and objects of various classes
                            int percent;

                            ProcessEscalateEmail objPro = new ProcessEscalateEmail();
                            #endregion
                            #region Get Total Resolution time define for particular SLA and Time Spent on Request
                            TotalResolutionTime = objPro.GetResolutionTimeInMins(obj.Slaid);
                            TotalTimeSpentonCall = objIncident.Get_TimeSpentonRequest(varIncidentid, siteid, varCreateDatetime, DateTime.Now.ToString());
                            if (TotalTimeSpentonCall < 0)
                            {
                                TotalTimeSpentonCall = 0;
                            }
                            #endregion
                            #region Calculate Percent
                            if (TotalResolutionTime != 0)
                            {
                                percent = (TotalTimeSpentonCall * 100) / TotalResolutionTime;
                            }
                            else
                            {
                                percent = 0;
                            }

                            #endregion

                            ColorScheme_mst objColor = new ColorScheme_mst();
                            colColor = objColor.Get_All_By_CallStatus(varStatusOpen);

                            foreach (ColorScheme_mst objCol in colColor)
                            {
                                if (objCol.Percnt_to != 0)
                                {
                                    if (percent >= objCol.Percnt && percent <= objCol.Percnt_to)
                                    {
                                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                    }
                                }
                                else
                                {
                                    if (percent >= objCol.Percnt)
                                    {
                                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                    }

                                }

                            }

                        }
                        else
                        {
                            ColorScheme_mst objColor = new ColorScheme_mst();
                            colColor = objColor.Get_All_By_CallStatus("NonSLA");

                            foreach (ColorScheme_mst objCol in colColor)
                            {

                                e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                            }

                        }
                    }

                }
                #endregion

                #region Apply Color Coding to Close Calls
                if (varStatusClose.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusClose);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        try { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname); }
                        catch (Exception ex)
                        { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("White"); }

                    }

                }
                #endregion

                #region Apply Color Coding to On Hold Calls
                if (varStatusOnHold.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusOnHold);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);

                    }

                }
                #endregion

                #region Apply Color Coding to Resolved Calls
                if (varStatusResolved.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusResolved);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);

                    }

                }
                #endregion

            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Exemplo n.º 33
0
        private void Theme_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Convert.ToInt16(Settings.Default["ThemeIndex"].ToString()) == themeBox.SelectedIndex)
            {
                return;
            }

            string fontColor       = "#000000";
            string backgroundColor = "#FFFFFF";

            Settings.Default["ThemeIndex"] = themeBox.SelectedIndex;

            switch (((ComboBoxItem)themeBox.SelectedItem).Content.ToString())
            {
            case "Default":
                fontColor       = "#FFFFFF";
                backgroundColor = "#253135";
                break;

            case "Light":
                fontColor       = "#000000";
                backgroundColor = "#FFFFFF";
                break;

            case "Dark":
                fontColor       = "#FFFFFF";
                backgroundColor = "#161616";
                break;

            case "Sini":
                fontColor       = "#079ec1";
                backgroundColor = "#002B37";
                break;

            case "Chocolate":
                fontColor       = "#a53622";
                backgroundColor = "#301C15";
                break;

            case "Vitamin":
                fontColor       = "#ACF74B";
                backgroundColor = "#282c34";
                break;

            case "Amethyst":
                fontColor       = "#B379E8";
                backgroundColor = "#302858";
                break;

            case "Pinky":
                fontColor       = "#FF00E2";
                backgroundColor = "#FFC6F5";
                break;

            case "Custom":
                fontColor       = Settings.Default["CustomFontColor"].ToString();
                backgroundColor = Settings.Default["CustomBackgroundColor"].ToString();
                break;
            }

            fontColorButton.Background       = new SolidColorBrush((Color)ColorConverter.ConvertFromString(fontColor));
            backgroundColorButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(backgroundColor));

            Settings.Default["FontColor"]       = fontColor;
            Settings.Default["BackgroundColor"] = backgroundColor;
            Settings.Default.Save();
            (this.Owner as MainWindow).ConfigureStyle();
        }
Exemplo n.º 34
0
        public static Style GetErrorToolTipStyle()
        {
            Style ErrorToolTipStyle = new Style(typeof(ToolTip));

            ErrorToolTipStyle.Setters.Add(new Setter(ToolTip.BackgroundProperty, new SolidColorBrush(UIConstants.ColorError)));
            ErrorToolTipStyle.Setters.Add(new Setter(ToolTip.ForegroundProperty, new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffffff"))));
            ErrorToolTipStyle.Setters.Add(new Setter(ToolTip.FontFamilyProperty, new FontFamily("Calibri")));
            ErrorToolTipStyle.Setters.Add(new Setter(ToolTip.FontWeightProperty, FontWeights.Regular));
            ErrorToolTipStyle.Setters.Add(new Setter(ToolTip.FontSizeProperty, 14d));
            return(ErrorToolTipStyle);
        }
Exemplo n.º 35
0
 SimpleHighlightingBrush(SerializationInfo info, StreamingContext context)
 {
     brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(info.GetString("color")));
     brush.Freeze();
 }
Exemplo n.º 36
0
        /// <summary>
        /// 将读取到的配置转换为color类型
        /// </summary>
        /// <param name="fir"></param>
        /// <param name="sec"></param>
        /// <returns></returns>
        public Color read_color(string fir, string sec)
        {
            Color color = (Color)ColorConverter.ConvertFromString(read(fir, sec));

            return(color);
        }
Exemplo n.º 37
0
        public void ChangeColor()
        {
            switch (_currentColor)
            {
            case 0:
                AxisBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF49A9C0"));
                AreaBrush = new LinearGradientBrush(new GradientStopCollection()
                {
                    new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#AA49A9C0"), Offset = 0
                    }, new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#5549A9C0"), Offset = 1
                    }
                }, 90);
                LineBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF49A9C0"));
                _currentColor = 1;
                break;

            case 1:
                AxisBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F4A758"));
                AreaBrush = new LinearGradientBrush(new GradientStopCollection()
                {
                    new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#AAF4A758"), Offset = 0
                    }, new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#55F4A758"), Offset = 1
                    }
                }, 90);
                LineBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F4A758"));
                _currentColor = 2;
                break;

            case 2:
                AxisBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E089B8"));
                AreaBrush = new LinearGradientBrush(new GradientStopCollection()
                {
                    new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#AAE089B8"), Offset = 0
                    }, new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#55E089B8"), Offset = 1
                    }
                }, 90);
                LineBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E089B8"));
                _currentColor = 3;
                break;

            case 3:
                AxisBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#AAAAAA"));
                AreaBrush = new LinearGradientBrush(new GradientStopCollection()
                {
                    new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#AAAAAAAA"), Offset = 0
                    }, new GradientStop()
                    {
                        Color = (Color)ColorConverter.ConvertFromString("#55DDDDDD"), Offset = 1
                    }
                }, 90);
                LineBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#AAAAAA"));
                _currentColor = 0;
                break;
            }
        }
Exemplo n.º 38
0
 private void MenuBackgroundItem_Click(object sender, RoutedEventArgs e)
 {
     (GridContent.Resources["BackgroundColor"] as SolidColorBrush).Color = (Color)ColorConverter.ConvertFromString((sender as MenuItem).Header.ToString());
 }
Exemplo n.º 39
0
        public static void LoadConfiguration()
        {
            try
            {
                var appSettings = ConfigurationManager.AppSettings;

                DefaultTraceColorList = new List <Color>();
                Color color;

                if (appSettings.Count == 0)
                {
                    // App Settings are empty
                }
                else
                {
                    foreach (var key in appSettings.AllKeys)
                    {
                        Console.WriteLine("Key: {0} Value: {1}", key, appSettings[key]);

                        switch (key)
                        {
                        case "MaxPixelValue":
                            MaxPixelValue = Convert.ToInt32(appSettings[key]);
                            break;

                        case "CameraSensorPixelWidth":
                            PixelWidth = Convert.ToInt32(appSettings[key]);
                            break;

                        case "CameraSensorPixelHeight":
                            PixelHeight = Convert.ToInt32(appSettings[key]);
                            break;

                        case "DatabaseConnectionString":
                            DatabaseConnectionString = appSettings[key];
                            break;

                        case "CompressionAlgorithm":
                            switch (appSettings[key].ToUpper())
                            {
                            case "GZIP":
                                CompressionAlgorithm = COMPRESSION_ALGORITHM.GZIP;
                                break;

                            case "NONE":
                            default:
                                CompressionAlgorithm = COMPRESSION_ALGORITHM.NONE;
                                break;
                            }
                            break;

                        case "DefaultReportFileDirectory":
                            DefaultReportFileDirectory = appSettings[key];
                            break;

                        case "CameraTargetTemperature":
                            CameraTargetTemperature = Convert.ToInt32(appSettings[key]);
                            break;

                        case "CameraDefaultCycleTime":
                            CameraDefaultCycleTime = Convert.ToInt32(appSettings[key]);
                            break;

                        case "FilterChangeSpeed":
                            FilterChangeSpeed = Convert.ToByte(appSettings[key]);
                            break;

                        case "ImageFileSaveLocation":
                            ImageFileSaveLocation = appSettings[key];
                            break;

                        case "Color1":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color2":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color3":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color4":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color5":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color6":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color7":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "Color8":
                            color = (Color)ColorConverter.ConvertFromString(appSettings[key]);
                            if (color != null)
                            {
                                DefaultTraceColorList.Add(color);
                            }
                            break;

                        case "VWorksUsername":
                            VWorksUsername = appSettings[key];
                            break;

                        case "VWorksPassword":
                            VWorksPassword = appSettings[key];
                            break;

                        case "VWorksProtocolFileDirectory":
                            VWorksProtocolFileDirectory = appSettings[key];
                            break;

                        case "UpSignalOptimizePercentCountThreshold":
                            UpSignalOptimizePercentCountThreshold = Convert.ToInt32(appSettings[key]);
                            break;

                        case "DownSignalOptimizePercentCountThreshold":
                            DownSignalOptimizePercentCountThreshold = Convert.ToInt32(appSettings[key]);
                            break;

                        case "UpDownSignalOptimizePercentCountThreshold":
                            UpDownSignalOptimizePercentCountThreshold = Convert.ToInt32(appSettings[key]);
                            break;

                        case "MaxTemperatureThresholdDeviation":
                            MaxTemperatureThresholdDeviation = Convert.ToInt32(appSettings[key]);
                            break;

                        case "EnclosureCameraIPAddress":
                            EnclosureCameraIPAddress = appSettings[key];
                            break;
                        }
                    }
                }
            }
            catch (ConfigurationErrorsException)
            {
                // Error reading app settings
            }
        }
Exemplo n.º 40
0
        // LiveCharts

        public ChartViewModel()
        {
            Bar.Add(new ChartModel()
            {
                Name = "Work time", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#019c7c")), WorkTimeSpan = new TimeSpan(6, 30, 0), ImagePath = "M12,20A7,7 0 0,1 5,13A7,7 0 0,1 12,6A7,7 0 0,1 19,13A7,7 0 0,1 12,20M19.03,7.39L20.45,5.97C20,5.46 19.55,5 19.04,4.56L17.62,6C16.07,4.74 14.12,4 12,4A9,9 0 0,0 3,13A9,9 0 0,0 12,22C17,22 21,17.97 21,13C21,10.88 20.26,8.93 19.03,7.39M11,14H13V8H11M15,1H9V3H15V1Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Break", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#e8ba53")), WorkTimeSpan = new TimeSpan(1, 10, 0), ImagePath = "M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Lunch", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#23c4bf")), WorkTimeSpan = new TimeSpan(0, 45, 0), ImagePath = "M15.5,21L14,8H16.23L15.1,3.46L16.84,3L18.09,8H22L20.5,21H15.5M5,11H10A3,3 0 0,1 13,14H2A3,3 0 0,1 5,11M13,18A3,3 0 0,1 10,21H5A3,3 0 0,1 2,18H13M3,15H8L9.5,16.5L11,15H12A1,1 0 0,1 13,16A1,1 0 0,1 12,17H3A1,1 0 0,1 2,16A1,1 0 0,1 3,15Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Meeting", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#008eb3")), WorkTimeSpan = new TimeSpan(0, 30, 0), ImagePath = "M4,15H6A2,2 0 0,1 8,17V19H9V17A2,2 0 0,1 11,15H13A2,2 0 0,1 15,17V19H16V17A2,2 0 0,1 18,15H20A2,2 0 0,1 22,17V19H23V22H1V19H2V17A2,2 0 0,1 4,15M11,7L15,10L11,13V7M4,2H20A2,2 0 0,1 22,4V13.54C21.41,13.19 20.73,13 20,13V4H4V13C3.27,13 2.59,13.19 2,13.54V4A2,2 0 0,1 4,2Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Study", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f4656d")), WorkTimeSpan = new TimeSpan(0, 20, 0), ImagePath = "M12,3L1,9L12,15L21,10.09V17H23V9M5,13.18V17.18L12,21L19,17.18V13.18L12,17L5,13.18Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "Exit note", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#a7bfd0")), WorkTimeSpan = new TimeSpan(0, 10, 0), ImagePath = "M12,15H10V13H12V15M18,15H14V13H18V15M8,11H6V9H8V11M18,11H10V9H18V11M20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20M4,6V18H20V6H4Z"
            });
            Bar.Add(new ChartModel()
            {
                Name = "To the doctor", Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#bb8f5b")), WorkTimeSpan = new TimeSpan(0, 10, 0), ImagePath = "M18,18.5A1.5,1.5 0 0,0 19.5,17A1.5,1.5 0 0,0 18,15.5A1.5,1.5 0 0,0 16.5,17A1.5,1.5 0 0,0 18,18.5M19.5,9.5H17V12H21.46L19.5,9.5M6,18.5A1.5,1.5 0 0,0 7.5,17A1.5,1.5 0 0,0 6,15.5A1.5,1.5 0 0,0 4.5,17A1.5,1.5 0 0,0 6,18.5M20,8L23,12V17H21A3,3 0 0,1 18,20A3,3 0 0,1 15,17H9A3,3 0 0,1 6,20A3,3 0 0,1 3,17H1V6C1,4.89 1.89,4 3,4H17V8H20M8,6V9H5V11H8V14H10V11H13V9H10V6H8Z"
            });

            //Users.Add(new ChartModel() { Employee = "Мусійовський Андрій", Department = "ДПК", WorkTimeSpan = new TimeSpan(8, 10, 0) }); // Наразі - для відображення в графіку
            //Users.Add(new ChartModel() { Employee = "Савка Тарас", Department = "ДПК", WorkTimeSpan = new TimeSpan(7, 59, 0) }); // Наразі - для відображення в графіку

            //SelectedItem = Users[0];

            foreach (var item in UserViewModel.UserInfo)
            {
                ChartSelectInfo.Add(new ChartModel()
                {
                    SelectedUser = item as User
                });
            }
            //SelectedChartInfo = ChartSelectInfo.First(o => o.SelectedUser.Login == Environment.UserName);
            SelectedChartInfo = ChartSelectInfo.First();


            //DtUser = ConnectBase.Select("SELECT * FROM " + ConnectBase.userBase);
            //for (int i = 0; i < DtUser.Rows.Count; i++)
            //{
            //    //NewUser = new User() { ID = (int)DtUser.Rows[i]["ID"], Login = DtUser.Rows[i]["Login"].ToString(), LastName = DtUser.Rows[i]["LastName"].ToString(), FirstName = DtUser.Rows[i]["FirstName"].ToString(), SurName = DtUser.Rows[i]["SurName"].ToString(), GroupName = DtUser.Rows[i]["GroupName"].ToString(), Position = DtUser.Rows[i]["Position"].ToString() };
            //    //UserInfo.Add(NewUser);
            //    UserInfo.Add(new User() { ID = (int)DtUser.Rows[i]["ID"], Login = DtUser.Rows[i]["Login"].ToString(), LastName = DtUser.Rows[i]["LastName"].ToString(), FirstName = DtUser.Rows[i]["FirstName"].ToString(), SurName = DtUser.Rows[i]["SurName"].ToString(), GroupName = DtUser.Rows[i]["GroupName"].ToString(), Position = DtUser.Rows[i]["Position"].ToString() });
            //}



            //ConnectBase.Select();
            Dt = ConnectBase.Select("SELECT UserBase.FirstName, Break_Type, Break_Notes, Start_Time, End_Time FROM " + ConnectBase.timeBase + ", UserBase WHERE TimeBase.User_ID = UserBase.ID"); // comboBoxUsers.Items[1].ToString()
            //Dt = ConnectBase.Select("SELECT * FROM " + ConnectBase.timeBase);

            //GetUsers();
            //UsersList.UserInfo


            // ----- LiveCharts
            PointLabel = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            SeriesCollection = new LiveCharts.SeriesCollection();

            foreach (var item in Bar)
            {
                TimeSpan timespan = new TimeSpan();
                int      index    = Bar.IndexOf(item);

                SeriesCollection.Add(new PieSeries {
                    Title  = Bar[index].Name + " - " + Bar[index].WorkTimeSpan,
                    Values = new ChartValues <ObservableValue> {
                        new ObservableValue(Bar[index].WorkTimeSpan.TotalMinutes)
                    },
                    DataLabels = true, LabelPoint = chartPoint => string.Format(@"{0:hh\:mm\:ss} ({1:P})", timespan = TimeSpan.FromMinutes(chartPoint.Y), chartPoint.Participation),
                });
            }
            // ----- LiveCharts


            //SeriesCollection = new SeriesCollection
            //{
            //    //new PieSeries { Title = Bar[0].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[0].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[1].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[1].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[2].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[2].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[3].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[3].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[4].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[4].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[5].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[5].WorkTimeSpan.TotalMinutes) }, DataLabels = true},
            //    //new PieSeries { Title = Bar[6].Name, Values = new ChartValues<ObservableValue> { new ObservableValue(Bar[6].WorkTimeSpan.TotalMinutes) }, DataLabels = true}

            //};
        }
Exemplo n.º 41
0
 public static Color ToColor(this string color)
 {
     return((Color)ColorConverter.ConvertFromString(color));
 }
Exemplo n.º 42
0
        //ControlBox back color change when mouse entered.
        private void ControlBoxMouseEnter(object sender, MouseEventArgs e)
        {
            Border target = (Border)e.Source;

            target.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#642950"));
        }
Exemplo n.º 43
0
    /// <summary>
    /// 转换成Color,默认Black
    /// </summary>
    /// <param name="color"></param>
    /// <returns></returns>
    public static System.Drawing.Color ToColor(object colorStr)
    {
        try
        {
            ColorConverter c = new ColorConverter();
            object obj = c.ConvertFrom(colorStr);
            Color color = (Color)obj;

            if (color != null)
                return color;
            else
                return System.Drawing.Color.Black;
        }
        catch
        {
            return System.Drawing.Color.Black;
        }
    }