示例#1
0
        //adding only one card to the wrap panel
        private void AddSingleCardBackToWrapPanel(BackColor color)
        {
            WrapPanelSelectableItem button = new WrapPanelSelectableItem
            {
                Height              = 110,
                Width               = 110,
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin              = new Thickness(0),
                ItemSelected        = Visibility.Collapsed,
                ItemHoovered        = Visibility.Collapsed,
                ImageSource         = CardBackImageSourceObtainer.GetBackImageSource(color),
                Tag = color,
            };

            //mouse enter and leave event
            button.MouseEnter += CardBackButton_MouseEnter;
            button.MouseLeave += CardBackButton_MouseLeave;
            button.Click      += AvatarButton_Click;

            CardBacksWrapPanel.Children.Add(button);

            var logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Info("Added one card back to the Wrap Panel: " + color.ToString());
        }
示例#2
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            base.RenderContents(output);

            if (this.DesignMode)
            {
                output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td style='vertical-align:middle;text-align:center'> Map: " + ClientID + "</td></tr></table>");

                //output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td width=300px height=100px style='vertical-align:middle;text-align:center'> Map: " + ClientID + "</td></tr></table>");

                //string w = WebUtil.UnitFormat(Width);
                //string h = WebUtil.UnitFormat(Height);

                //output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td width="+w+" height="+h+" style='vertical-align:middle;text-align:center'> DSMap: " + ClientID  + "</td></tr></table>");
            }
            else
            {
                if (Page.IsPostBack)
                {
                    GDIMap m   = ControlMap;
                    string htm = redraw(ref m);
                    output.Write(htm);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Synchronizes current Console position and color attributes.
        /// </summary>
        ///
        private bool SyncConsolePositionAndAttributes()
        {
            string c1 = "-", c2 = "-", c3 = "-";

            // Update Console cursor position, if different
            //
            if (CursorTop != Y || CursorLeft != X)
            {
                Console.SetCursorPosition(CursorLeft = X, CursorTop = Y);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c1 = string.Format("{0,4} {1,4} {2,6}", Y, X, Y * Width + X);
                });
                #endregion
            }

            // Update current Console background color, if different
            //
            if (BackColor != Buffer.Area[Y, X].BackColor)
            {
                Console.BackgroundColor = Map(
                    BackColor           = Buffer.Area[Y, X].BackColor);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c2 = BackColor.ToString();
                });
                #endregion
            }

            // Update current Console foreground color, if different
            //
            if (ForeColor != Buffer.Area[Y, X].ForeColor)
            {
                Console.ForegroundColor = Map(
                    ForeColor           = Buffer.Area[Y, X].ForeColor);

                #region [ Trace ]
                Debug.IfTracing(TraceFlag.Updates, delegate
                {
                    c3 = ForeColor.ToString();
                });
                #endregion
            }

            #region [ Trace ]
            Debug.IfTracing(TraceFlag.Updates, delegate
            {
                Debug.TraceTimeStamp();
                Debug.Trace("{0,16}{1,12}{2,12} ", c1, c2, c3);
            });
            #endregion

            return(true);
        }
示例#4
0
        /// <summary>
        /// Get custom css inline style
        /// </summary>
        /// <param name="autoFit">
        /// A value indicating whether the control's html width and height should be calculated by browser.
        /// </param>
        /// <returns>Custom css inline style</returns>
        protected virtual string GetCustomStyle(bool autoFit = false)
        {
            string widthString  = autoFit ? "auto" : string.Format("{0}pt", Width);
            string heightString = autoFit ? "auto" : string.Format("{0}pt", Height);

            string style = string.Format(StyleFormat, ForeColor.ToString("RGB"), BackColor.ToString("RGB"),
                                         TextAlign.ToString().ToLower(), Font.ToString("W"), heightString, widthString);

            return(style);
        }
示例#5
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            if (this.DesignMode)
            {
                output.Write("<table style='border-color:Black;background-color:" + BackColor.ToString() + "'><tr><td style='vertical-align:middle;text-align:center'> ToolBar: " + ClientID + "</td></tr></table>");
            }
            else
            {
                List <WebButton> _buttons = Buttons;

                string htm   = "";
                string MapID = WebMapID;
                string ControlID;

                for (int i = 0; i < _buttons.Count; i++)
                {
                    WebButton b = _buttons[i];

                    if (b.Type != WebButtonType.Space)
                    {
                        ControlID = "Tool_" + MapID + i.ToString();
                    }
                    else
                    {
                        ControlID = "Space_" + MapID + i.ToString();
                    }

                    string command = b.Command.Replace("<WebMapID>", MapID);
                    command = command.Replace("<index>", ControlID);

                    if (b.Type != WebButtonType.Space)
                    {
                        htm += "<input id=\"" + ControlID +
                               "\" type=\"button" +
                               "\" title=\"" + b.ToolTip +
                               "\" onclick=\"" + command +
                               "\" ondrag(event)=\"return false\" onSelectStart=\"return false\"" +
                               "\" style=\"" + b.Style +
                               " background-image: url(" + b.ImageURL + ");" +
                               " background-color: transparent; border-width: 2px; height: 28px; width: 28px;\" />";
                    }
                    else
                    {
                        htm += "<img id=\"" + ControlID +
                               "\" title=\"" + b.ToolTip +
                               "\" onclick=\"" + command +
                               "\" ondrag(event)=\"return false\" onSelectStart=\"return false\"" +
                               " src=\"" + b.ImageURL + "\" style=\"" + b.Style + "\" />";
                    }
                }

                output.Write(htm);
            }
        }
示例#6
0
 protected override void OnPaintBackground(PaintEventArgs pevent)
 {
     base.OnPaintBackground(pevent);
     if (Game.Initalized)
     {
         pevent.Graphics.Clear(Game.Palette[int.Parse(BackColor.ToString(), System.Globalization.NumberStyles.HexNumber)]);
     }
     else
     {
         pevent.Graphics.Clear(Color.Black);
     }
     pevent.Graphics.DrawRectangle(Pens.White, ClientRectangle);
 }
        private void Save(object obj)
        {
            Settings.Default.CharacterInterval = CharacterInterval;
            Settings.Default.CharacterMargin   = CharacterMargin;
            Settings.Default.FontSize          = FontSize;
            Settings.Default.TimeFontSize      = TimeFontSize;
            Settings.Default.BackColor         = BackColor.ToString();
            Settings.Default.ForeColor         = ForeColor.ToString();
            Settings.Default.DisplayTime       = DisplayTime;
            Settings.Default.UseAllScreens     = UseAllScreens;
            Settings.Default.TimeFormat        = TimeFormat;

            Settings.Default.Save();
            parentWindow.Close();
        }
        public static BitmapImage GetBackImageSource(BackColor color)
        {
            BitmapImage output = null;

            try
            {
                output = new BitmapImage(new Uri($"pack://application:,,,/CardGraphicsLibraryHandler;component/Resources/backgraphics{color.ToString()}.png"));
            }
            catch (Exception ex)
            {
                var logger = NLog.LogManager.GetCurrentClassLogger();
                logger.Error($"Error while reading back card image {color.ToString()} image from resources: {ex.Message}.");
            }

            return(output);
        }
示例#9
0
        public void SaveSettings()
        {
            // Открываем узел appSettings, в котором содержится перечень настроек.
            XmlNode node = doc.SelectSingleNode("//appSettings");

            if (node == null)
            {
                node = doc.CreateNode(XmlNodeType.Element, "appSettings", "");
                XmlElement root = doc.DocumentElement;
                root.AppendChild(node);
            }

            // Массив ключей (создан для упрощения обращения к файлу конфигурации).
            string[] keys = new string[] { "BackColor",
                                           "TextColor",
                                           "TextSize",
                                           "TextFont" };

            // Массив значений (создан для упрощения обращения к файлу конфигурации).
            string[] values = new string[] { BackColor.ToString(),
                     TextColor.ToString(),
                     TextSize.ToString(),
                     TextFont.ToString() };

            // Цикл модификации файла конфигурации.
            for (int i = 0; i < keys.Length; i++)
            {
                // Обращаемся к конкретной строке по ключу.
                XmlElement element = node.SelectSingleNode(string.Format("//add[@key='{0}']", keys[i])) as XmlElement;

                // Если строка с таким ключем существует - записываем значение.
                if (element != null)
                {
                    element.SetAttribute("value", values[i]);
                }
                else
                {
                    // Иначе: создаем строку и формируем в ней пару [ключ]-[значение].
                    element = doc.CreateElement("add");
                    element.SetAttribute("key", keys[i]);
                    element.SetAttribute("value", values[i]);
                    node.AppendChild(element);
                }
            }
            // Сохраняем результат модификации.
            doc.Save(Assembly.GetExecutingAssembly().Location + ".config");
        }
示例#10
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            output.WriteBeginTag("table");
            output.WriteAttribute("cellpadding", "5");
            output.WriteAttribute("cellspacing", "0");
            output.WriteAttribute("border", "0");
            output.WriteAttribute("align", "center");
            output.WriteAttribute("width", Width.Value.ToString());
            output.Write(HtmlTextWriter.TagRightChar);

            output.WriteFullBeginTag("tr");
            output.WriteBeginTag("td");
            output.WriteAttribute("bgcolor", BackColor.ToString());
            output.Write(HtmlTextWriter.TagRightChar);

            output.WriteBeginTag("span");
            output.WriteAttribute("style", "borderWidth:0; borderColor:#ffffff; width:" + InnerWidth.ToString() + "; height:" + Height.Value.ToString() + ";\">");
            output.Write("<ilayer width=" + InnerWidth.ToString() + " height=" + Height.ToString() + " name=\"slider1\" bgcolor=\"" + BackColor.ToString() + " visibility=hide>");
            output.Write("<layer name=\"slider2\" onMouseOver=\"sspeed=0;\" onMouseOut=\"sspeed=" + scrollSpeed.ToString() + "\"></layer>");
            output.Write("</ilayer>");

            output.Write("<script language=\"JavaScript\">");
            output.Write("if (document.all){");
            output.Write("document.writeln('<marquee id=\"ieslider\" scrollAmount=" + scrollSpeed.ToString() + " width=" + InnerWidth.ToString() + " height=" + Height.ToString() + " direction=up style=\"border:0 solid grey;background-color:#ffffff\">')");
            output.Write("document.writeln(mymessage)");
            output.Write("ieslider.onmouseover=new Function(\"ieslider.scrollAmount=0\")");
            output.Write("ieslider.onmouseout=new Function(\"if (document.readyState=='complete') ieslider.scrollAmount=" + scrollSpeed.ToString() + "\")");
            output.Write("document.write('</marquee>')");
            output.Write("}");
            output.Write("if (document.getElementById&&!document.all){ ");
            output.Write("document.write('<div style=\"position:relative;overflow:hidden;width:" + InnerWidth.ToString() + ";height:" + Height.ToString() + ";clip:rect(0 302 102 0); background-color:#ffffff;border:0px solid white;\" onMouseover=\"sspeed=0;\" onMouseout=\"sspeed=" + scrollSpeed.ToString() + "\">')");
            output.Write("document.write('<div id=\"slider\" style=\"position:relative;width:&{swidth};\">')");
            output.Write("document.write('</div></div>')");
            output.Write("}");
            output.Write("</script>");

            output.WriteEndTag("span");
            output.WriteEndTag("td");
            output.WriteEndTag("tr");
            output.WriteEndTag("table");
        }
        public void SaveSettings()
        {
            XmlNode node = doc.SelectSingleNode("//appSettings");

            if (node == null)
            {
                node = doc.CreateNode(XmlNodeType.Element, "appSettings", "");
                XmlElement root = doc.DocumentElement;
                root.AppendChild(node);
            }

            string[] keys = new string[] { "BackColor",
                                           "TextColor",
                                           "TextSize",
                                           "TextFont" };

            string[] values = new string[] { BackColor.ToString(),
                     TextColor.ToString(),
                     TextSize.ToString(),
                     TextFont.ToString() };


            for (int i = 0; i < keys.Length; i++)
            {
                XmlElement element = node.SelectSingleNode(string.Format("//add[@key='{0}']", keys[i])) as XmlElement;
                if (element != null)
                {
                    element.SetAttribute("value", values[i]);
                }
                else
                {
                    element = doc.CreateElement("add");
                    element.SetAttribute("key", keys[i]);
                    element.SetAttribute("value", values[i]);
                    node.AppendChild(element);
                }
            }

            doc.Save(Assembly.GetExecutingAssembly().Location + ".config");
        }
示例#12
0
        public void Save(System.IO.FileStream fs, System.Xml.XmlWriter fi)
        {
            UInt16 eSize = (UInt16)(Text.Length + 14);

            utftUtils.Save2Bytes(fs, eSize);
            fs.WriteByte((byte)GetItemTypeNumber());
            fs.WriteByte(ID);
            utftUtils.Save2Bytes(fs, (UInt16)X);
            utftUtils.Save2Bytes(fs, (UInt16)Y);
            fs.WriteByte((byte)width);
            fs.WriteByte((byte)heigth);
            UInt16 clr = utftUtils.GetUTFTColorBytes(BackColor);

            utftUtils.Save2Bytes(fs, clr);
            clr = utftUtils.GetUTFTColorBytes(FontColor);
            utftUtils.Save2Bytes(fs, clr);
            fs.WriteByte(Convert.ToByte(_canSelect));
            fs.WriteByte((byte)Text.Length);
            char[] arr = Text.ToCharArray();
            for (int i = 0; i < Text.Length; i++)
            {
                fs.WriteByte((byte)arr[i]);
            }

            fi.WriteStartElement("Element");
            fi.WriteElementString("ItemType", ItemType);
            fi.WriteElementString("ID", ID.ToString());
            fi.WriteElementString("X", X.ToString());
            fi.WriteElementString("Y", Y.ToString());
            fi.WriteElementString("Width", width.ToString());
            fi.WriteElementString("Height", heigth.ToString());
            fi.WriteElementString("BackColor", BackColor.ToString());
            fi.WriteElementString("FontColor", FontColor.ToString());
            fi.WriteElementString("CanSelect", CanSelect.ToString());
            fi.WriteElementString("Text", Text);
            fi.WriteElementString("ItemName", ItemName);
            fi.WriteEndElement();
        }
示例#13
0
 public override string ToString()
 {
     return(ForeColor.ToString() + ", " + BackColor.ToString() + ", " + BorderColor.ToString());
 }
示例#14
0
        public void Save(string MainFileName)
        {
            if (MainFileName.Substring(MainFileName.Length - 4) != ".scr")
            {
                MainFileName = MainFileName + ".scr";
            }
            string IDsFileName  = MainFileName.Substring(0, MainFileName.Length - 4) + ".ids";
            string DefsFileName = IDsFileName.Substring(0, IDsFileName.Length - 4) + ".h";

            System.IO.FileStream   fs = new System.IO.FileStream(MainFileName, System.IO.FileMode.Create);
            System.Xml.XmlWriter   fi = System.Xml.XmlWriter.Create(IDsFileName);
            System.IO.StreamWriter fd = new System.IO.StreamWriter(DefsFileName);

            //pnl.Image.Save(null, System.Drawing.Imaging.ImageFormat.Bmp);
            fi.WriteStartDocument();
            fi.WriteStartElement("Document");
            fi.WriteStartElement("Screen");
            fi.WriteElementString("SCREEN_Width", Width.ToString());
            fi.WriteElementString("SCREEN_Height", Height.ToString());
            fi.WriteElementString("SCREEN_BackColor", BackColor.ToString());
            fi.WriteElementString("SCREEN_FontColor", FontColor.ToString());
            fi.WriteElementString("SCREEN_ABorderColor", ActiveBorderColor.ToString());
            fi.WriteElementString("SCREEN_PBorderColor", PassiveBorderColor.ToString());
            if (pnl.Image != null)
            {
                string aname = String.Format("{0}\\{1}", System.IO.Path.GetDirectoryName(MainFileName), ScreenName);
                utftUtils.SaveRAWImage(aname, pnl.Image);
                fi.WriteElementString("Desctop", ScreenName);
            }
            fi.WriteEndElement();

            byte lbl = 0;
            byte btn = 0;

            foreach (KeyValuePair <string, TInterfaceElement> e in listitem)
            {
                if (e.Value.GetItemTypeNumber() == 3)
                {
                    e.Value.ID = lbl++;
                }
                else
                {
                    e.Value.ID = btn++;
                }
            }
            fs.WriteByte((byte)(13 + ScreenName.Length));// размер данных экрана
            utftUtils.Save2Bytes(fs, (UInt16)Width);
            utftUtils.Save2Bytes(fs, (UInt16)Height);

            UInt16 clr = utftUtils.GetUTFTColorBytes(BackColor);

            utftUtils.Save2Bytes(fs, clr);
            clr = utftUtils.GetUTFTColorBytes(FontColor);
            utftUtils.Save2Bytes(fs, clr);
            clr = utftUtils.GetUTFTColorBytes(ActiveBorderColor);
            utftUtils.Save2Bytes(fs, clr);
            clr = utftUtils.GetUTFTColorBytes(PassiveBorderColor);
            utftUtils.Save2Bytes(fs, clr);

            fs.WriteByte((byte)lbl);
            fs.WriteByte((byte)btn);
            fs.WriteByte((byte)ScreenName.Length);
            for (int i = 0; i < ScreenName.Length; i++)
            {
                fs.WriteByte(Convert.ToByte(ScreenName[i]));
            }
            fi.WriteStartElement("Elements");

            foreach (KeyValuePair <string, TInterfaceElement> e in listitem)
            {
                e.Value.Save(fs, fi);
                if (e.Value.ItemType != "Label")
                {
                    fd.WriteLine(String.Format("#define {0} {1}", e.Value.ItemName, e.Value.ID));
                }
            }

            fi.WriteEndElement();

            fi.WriteEndElement();
            fi.WriteEndDocument();

            fs.Close();
            fi.Close();
            fd.Close();

            fs.Dispose();
            fd.Dispose();
        }