public MemoryStream GetThumbnailStream(string absolutePath, int width, int height) {
			var builder = new ImageBuilder();

			var stream = builder.BuildThumb(absolutePath, width, height);

			var fileName = Path.GetFileNameWithoutExtension(absolutePath);
			var fileExtension = Path.GetExtension(absolutePath);

			if (!Directory.Exists(_filesPath)) {
				Directory.CreateDirectory(_filesPath);
			}

			var newPath = GetThumbPath(width, height, fileExtension, _filesPath, fileName);

			if (!File.Exists(newPath)) {

				using (var file = new FileStream(newPath, FileMode.Create, System.IO.FileAccess.Write))
				{
					stream.Seek(0, 0);
					stream.CopyTo(file);

					file.Flush();
				}
			}

			stream.Seek(0, 0);
			return stream;
		}
        public BitmapImage TakeScreenshot()
        {
#if GUI_DISABLED
            throw new RecoverableException("Taking screenshots with a disabled GUI is not supported");
#else
            if (buffer == null)
            {
                throw new RecoverableException("Frame buffer is empty.");
            }

            // this is inspired by FrameBufferDisplayWidget.cs:102
            var pixelFormat = PixelFormat.RGBA8888;
    #if PLATFORM_WINDOWS
            pixelFormat = PixelFormat.BGRA8888;
    #endif

            var converter = PixelManipulationTools.GetConverter(Format, Endianess, pixelFormat, ELFSharp.ELF.Endianess.BigEndian);
            var outBuffer = new byte[Width * Height * pixelFormat.GetColorDepth()];
            converter.Convert(buffer, ref outBuffer);

            var img = new ImageBuilder(Width, Height).ToBitmap();
            img.Copy(outBuffer);
            return(img);
#endif
        }
示例#3
0
 protected void InvalidateImageBuilder()
 {
     lock (_imageBuilderSync) if (_imageBuilder != null)
         {
             _imageBuilder = _imageBuilder.Create(plugins.ImageBuilderExtensions, plugins, pipeline, pipeline);
         }
 }
示例#4
0
 public static Image AsImage(Action <Context> render, Size size)
 {
     using (var ib = new ImageBuilder(size.Width, size.Height)) {
         render(ib.Context);
         return(ib.ToBitmap(ImageFormat.ARGB32));
     }
 }
 public void Build_CreatesTargetDirectory_WhenAskedTo()
 {
     using (var source = GetBitmapStream(100, 100))
         using (var targetStream = new MemoryStream())
         {
             source.Seek(1, SeekOrigin.Begin);
             var originalPosition = source.Position;
             var directory        = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
             Assume.That(!Directory.Exists(directory));
             var destinationPath = Path.Combine(directory, "test.jpg");
             try
             {
                 var instructions = new Instructions {
                     Width = 50
                 };
                 ImageBuilder.Build(source, destinationPath, true, instructions);
                 Assert.True(Directory.Exists(directory));
             }
             finally
             {
                 File.Delete(destinationPath);
                 Directory.Delete(directory, false);
             }
         }
 }
示例#6
0
        public EquipSelectedScreen(SimulatorContext context, IList <PlayerCharacter> _list, BaseGoods goods) : base(context)
        {
            _goods    = goods;
            list      = _list;
            bg        = Context.Util.GetFrameBitmap(16 * 5 + 6, 6 + 16 * list.Count);
            itemsText = ExtensionFunction.DyadicArrayByte(list.Count, 11);//new byte[list.Count][11];

            for (int i = 0; i < itemsText.Length; i++)
            {
                itemsText[i] = new byte[11];
            }

            for (int i = 0; i < itemsText.Length; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    itemsText[i][j] = (byte)' ';
                }
                try
                {
                    byte[] tmp = list[i].Name.GetBytes();
                    Array.Copy(tmp, 0, itemsText[i], 0, tmp.Length);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
        /// <summary>
        /// 系统菜单界面
        /// </summary>
        /// <param name="context"></param>
        public ScreenMenuSystem(SimulatorContext context) : base(context)
        {
            _background = Context.Util.GetFrameBitmap(109 - 39 + 1, 91 - 29 + 1);
            var   canvas = context.GraphicsFactory.NewCanvas();
            Paint paint  = new Paint(Constants.COLOR_BLACK);

            ImageBuilder arrowUpImg = Context.GraphicsFactory.NewImageBuilder(7, 4);

            canvas.SetBitmap(arrowUpImg);
            canvas.DrawColor(Constants.COLOR_WHITE);
            canvas.DrawLine(3, 0, 4, 0, paint);
            canvas.DrawLine(2, 1, 5, 1, paint);
            canvas.DrawLine(1, 2, 6, 2, paint);
            canvas.DrawLine(0, 3, 7, 3, paint);

            ImageBuilder arrowDownImg = Context.GraphicsFactory.NewImageBuilder(7, 4);

            canvas.SetBitmap(arrowDownImg);
            canvas.DrawColor(Constants.COLOR_WHITE);
            canvas.DrawLine(0, 0, 7, 0, paint);
            canvas.DrawLine(1, 1, 6, 1, paint);
            canvas.DrawLine(2, 2, 5, 2, paint);
            canvas.DrawLine(3, 3, 4, 3, paint);

            _arrowImgs = new ImageBuilder[] { arrowDownImg, arrowUpImg };
        }
        /// <summary>
        /// 通用菜单
        /// </summary>
        /// <param name="context"></param>
        public ScreenCommonMenu(IEnumerable <string> items, Action <int> Callback, SimulatorContext context) : base(context)
        {
            var byteItmes = items.Select(m => m.GetBytes()).ToArray();

            var colCount = byteItmes.Max(m => m.Length);

            var width  = 8 * colCount;
            var height = 16 * byteItmes.Length;

            _background = Context.Util.GetFrameBitmap(width + Padx * 2, height + Pady * 2);

            _menuItemsRect = new Rectangle(
                (Constants.SCREEN_WIDTH - width) / 2,
                (Constants.SCREEN_HEIGHT - height) / 2,
                width,
                height);

            _menuItems = byteItmes.Select(m =>
            {
                if (m.Length < colCount)
                {
                    var nm = new byte[colCount];
                    Array.Copy(m, 0, nm, 0, m.Length);
                    return(nm);
                }
                else
                {
                    return(m);
                }
            }).ToArray();
            this.Callback = Callback;
        }
        public void PatternsAndImages(Context ctx, double x, double y)
        {
            ctx.Save();
            ctx.Translate(x, y);

            ctx.SetColor(Colors.Black);
            // Dashed lines

            ctx.SetLineWidth(2);
            ctx.SetLineDash(15, 10, 10, 5, 5);
            ctx.Rectangle(10, 10, 100, 100);
            ctx.Stroke();
            ctx.SetLineDash(0);

            // Image
            var          arcColor = new Color(1, 0, 1);
            ImageBuilder ib       = new ImageBuilder(30, 30);

            ib.Context.Arc(15, 15, 15, 0, 360);
            ib.Context.SetColor(arcColor);
            ib.Context.Fill();
            ib.Context.SetColor(Colors.DarkKhaki);
            ib.Context.Rectangle(0, 0, 5, 5);
            ib.Context.Fill();
            var img = ib.ToVectorImage();

            ctx.DrawImage(img, 0, 0);
            ctx.DrawImage(img, 0, 50, 50, 10);

            ctx.Arc(100, 100, 15, 0, 360);
            arcColor.Alpha = 0.4;
            ctx.SetColor(arcColor);
            ctx.Fill();

            // ImagePattern

            ctx.Save();

            ctx.Translate(x + 130, y);
            ctx.Pattern = new ImagePattern(img);
            ctx.Rectangle(0, 0, 100, 100);
            ctx.Fill();
            ctx.Restore();

            ctx.Restore();

            // Setting pixels

            ctx.SetLineWidth(1);
            for (int i = 0; i < 50; i++)
            {
                for (var j = 0; j < 50; j++)
                {
                    Color c = Color.FromHsl(0.5, (double)i / 50d, (double)j / 50d);
                    ctx.Rectangle(i, j, 1, 1);
                    ctx.SetColor(c);
                    ctx.Fill();
                }
            }
        }
示例#10
0
        /// <summary>
        /// 战斗胜利消息界面
        /// </summary>
        /// <param name="context"></param>
        /// <param name="top">消息显示Y坐标</param>
        /// <param name="msg"></param>
        public MsgScreen(SimulatorContext context, int top, string msg) : base(context)
        {
            byte[] msgData;
            try
            {
                msgData = msg.GetBytes();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                msgData = new byte[0];
            }

            ResImage side = Context.LibData.GetImage(2, 8);

            _messageImg = Context.GraphicsFactory.NewImageBuilder(msgData.Length * 8 + 8, 24);
            ICanvas canvas = Context.GraphicsFactory.NewCanvas(_messageImg);;

            canvas.DrawColor(Constants.COLOR_WHITE);
            side.Draw(canvas, 1, 0, 0);
            side.Draw(canvas, 2, _messageImg.Width - 3, 0);

            Paint paint = new Paint(PaintStyle.FILL_AND_STROKE, Constants.COLOR_BLACK);

            canvas.DrawLine(0, 1, _messageImg.Width, 1, paint);
            canvas.DrawLine(0, 22, _messageImg.Width, 22, paint);
            TextRender.DrawText(canvas, msgData, 4, 4);

            _left = (160 - _messageImg.Width) / 2;
            _top  = top;
        }
示例#11
0
        public void Orientation()
        {
            for (var i = 1; i <= 8; i++)
            {
                var resourceName = string.Format("Tests.Resources.orientation.Landscape_{0}.jpg", i);
                var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

                byte[] content;
                using (var output = new MemoryStream())
                {
                    resource.CopyTo(output);
                    content = output.ToArray();
                }

                var media = new MediaBuilder(this.Session).WithContent(content).Build();
                media.MediaType = new MediaTypes(this.Session).Infer(media.Content);

                var image = new ImageBuilder(this.Session).WithOriginal(media).Build();

                this.Session.Derive(true);

                using (Stream stream = new MemoryStream(image.Responsive.Content))
                {
                    var responsive = new Bitmap(stream);
                    responsive.Width.ShouldEqual(600);
                    responsive.Height.ShouldEqual(450);
                }
            }
        }
 public ImageBuilder Avatar(Trakker.Data.File file)
 {
     var component = new ImageBase(AssetManager);
     var builder = new ImageBuilder(component, new AvatarImageProfile(), new ImageHtmlBuilder(component), Writer);
     builder.Src(Path.Combine(file.Path, file.FileName));
     return builder;
 }
        /// <summary>
        /// 多人装备选择界面
        /// </summary>
        /// <param name="context"></param>
        /// <param name="characters">角色列表</param>
        /// <param name="goods">当前选择进行装备的装备</param>
        public MutilCharacterEquipScreen(SimulatorContext context, List <PlayerCharacter> characters, BaseGoods goods) : base(context)
        {
            //HACK 此处需要测试是否正常运行
            _characters = characters;
            _goods      = goods;

            _background = Context.Util.GetFrameBitmap(16 * 5 + 6, 6 + 16 * _characters.Count);
            _names      = ExtensionFunction.DyadicArrayByte(_characters.Count, 11);//new byte[list.Count][11];
            for (int i = 0; i < _names.Length; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    _names[i][j] = (byte)' ';
                }
                try
                {
                    byte[] tmp = _characters[i].Name.GetBytes();
                    Array.Copy(tmp, 0, _names[i], 0, tmp.Length);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
示例#14
0
        private Texture GeneratePlanetTexture(Vector2Dd texSize)
        {
            var imgSize = texSize;

            module           = new Perlin(4, 0.5, NoiseQuality.Best, 5, 1.3, random.Next(0, 1024));
            heightMapBuilder = new PlanarNoiseMapBuilder((uint)imgSize.X, (uint)imgSize.Y, 0, module, 2, 6, 1, 5, true);
            heightMap        = heightMapBuilder.Build();

            var texColors = new GradientColour();

            texColors.AddGradientPoint(-1, System.Drawing.Color.DimGray);
            texColors.AddGradientPoint(-0.7, System.Drawing.Color.Olive);
            texColors.AddGradientPoint(0.0, System.Drawing.Color.SteelBlue);
            texColors.AddGradientPoint(0.8, System.Drawing.Color.Tan);
            texColors.AddGradientPoint(1, System.Drawing.Color.DarkKhaki);
            var renderer = new ImageBuilder(heightMap, texColors);

            System.Drawing.Image renderedImg = renderer.Render();
            var img = new Bitmap(renderedImg);

            img.Save("planetTex.png", ImageFormat.Png);

            var returnTex = Driver.GetTexture("planetTex.png");

            return(returnTex);
        }
示例#15
0
        public TextRender(SimulatorContext context) : base(context)
        {
            LoadData();

            _hzkBitmapBuilder = context.GraphicsFactory.NewImageBuilder(16, 16);
            _ascBitmapBuilder = context.GraphicsFactory.NewImageBuilder(8, 16);
        }
示例#16
0
        protected new string RenderRecentIcons()
        {
            int            num            = 0;
            ListString     recentIcons    = RecentIcons;
            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter());
            ImageBuilder   imageBuilder   = new ImageBuilder()
            {
                Width  = 32,
                Height = 32
            };

            foreach (string str in recentIcons)
            {
                var source = Images.GetThemedImageSource(str, ImageDimension.id32x32);

                var isExists = File.Exists(FileUtil.MapPath(source));

                if (isExists)
                {
                    imageBuilder.Src = source;
                    imageBuilder.Alt = StringUtil.Capitalize(FileUtil.GetFileNameWithoutExtension(str).Replace("_", " "));
                    imageBuilder.Attributes.Set("sc_path", str);
                    imageBuilder.Class = "scRecentIcon";
                    htmlTextWriter.Write(imageBuilder.ToString());
                    ++num;
                }
            }
            if (num == 0)
            {
                htmlTextWriter.Write("<div align=\"center\" style=\"padding:32px 0px 0px 0px\"><i>");
                htmlTextWriter.Write(Translate.Text("There are no icons to display."));
                htmlTextWriter.Write("</i></div>");
            }
            return(htmlTextWriter.InnerWriter.ToString());
        }
示例#17
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            if (!PlugIn.PlugInExists(GrasshopperGuid, out bool loaded, out bool loadProtected))
            {
                return;
            }

            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var buttonData = new PushButtonData
                             (
                "cmdRhinoInside.Grasshopper", "Grasshopper",
                thisAssembly.Location,
                MethodBase.GetCurrentMethod().DeclaringType.FullName
                             );

            if (ribbonPanel.AddItem(buttonData) is PushButton pushButton)
            {
                pushButton.ToolTip    = "Toggle Grasshopper window visibility";
                pushButton.LargeImage = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.Grasshopper.png");
                pushButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://www.grasshopper3d.com/"));
                pushButton.Enabled = !loadProtected;
            }
        }
示例#18
0
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            var builder = new ImageBuilder();

            Config(builder);
            return(builder);
        }
示例#19
0
        public static void ProcessImage(IEnumerable <IPlugin> extensions, object source, object target = null, ResizeSettings resizeSettings = null)
        {
            resizeSettings = resizeSettings ?? new ResizeSettings()
            {
            };

            target = target ?? new MemoryStream();

            var builderConfig = new ImageResizer.Configuration.Config();

            foreach (var extension in extensions)
            {
                extension.Install(builderConfig);
            }

            var imageBuilder = new ImageBuilder(builderConfig.Plugins.ImageBuilderExtensions, builderConfig.Plugins,
                                                builderConfig.Pipeline, builderConfig.Pipeline);

            Console.WriteLine("processing " + source);
            if (source is string && source.ToString().StartsWith("http"))
            {
                source = new MemoryStream(new WebClient().DownloadData(source.ToString()));
            }

            imageBuilder.Build(source, target, resizeSettings, false);
        }
示例#20
0
 private void RenderItems(HtmlTextWriter output)
 {
     Assert.ArgumentNotNull(output, "output");
     foreach (string str in this.Value.Split(new char[] { '|' }))
     {
         if (!string.IsNullOrEmpty(str))
         {
             Item         item    = this.Database.GetItem(str);
             ImageBuilder builder = new ImageBuilder
             {
                 Width  = 0x80,
                 Height = 0x80,
                 Margin = "0px 4px 0px 0px",
                 Align  = "left"
             };
             if (item == null)
             {
                 builder.Src = "Applications/16x16/forbidden.png";
                 output.Write("<div>");
                 builder.Render(output);
                 output.Write(Translate.Text("Item not found: {0}", new object[] { str }));
                 output.Write("</div>");
             }
             else
             {
                 builder.Src = item.Appearance.Icon;
                 output.Write("<div title=\"" + item.Paths.ContentPath + "\">");
                 builder.Render(output);
                 //output.Write(item.DisplayName);
                 output.Write("</div>");
             }
         }
     }
 }
示例#21
0
 public override void Draw(ImageBuilder imageBuilder, int left, int top)
 {
     using (var g = GetGraphics())
     {
         g.DrawImage((imageBuilder as NewImageBuilder).Instance, left, top);
     }
 }
示例#22
0
        public string Execute([NotNull] string databaseName, [NotNull] string id, bool includeInheritedFields)
        {
            Assert.ArgumentNotNull(databaseName, nameof(databaseName));
            Assert.ArgumentNotNull(id, nameof(id));

            var database = Factory.GetDatabase(databaseName);

            if (database == null)
            {
                throw new Exception("Database not found");
            }

            var item = database.GetItem(id);

            if (item == null)
            {
                throw new Exception("Item not found.");
            }

            var template = TemplateManager.GetTemplate(item.ID, item.Database);

            if (template == null)
            {
                throw new Exception("Template not found.");
            }

            var writer = new StringWriter();
            var output = new XmlTextWriter(writer);

            output.WriteStartElement("template");
            output.WriteAttributeString("name", template.Name);
            output.WriteAttributeString("id", template.ID.ToString());
            output.WriteAttributeString("basetemplates", GetBaseTemplates(template, database));
            output.WriteAttributeString("icon", ImageBuilder.ResizeImageSrc(item.Appearance.Icon, 32, 32));
            output.WriteAttributeString("standardvaluesitemid", item[FieldIDs.StandardValues]);
            output.WriteAttributeString("path", item.Paths.Path);

            List <TemplateSection> sections;

            if (includeInheritedFields)
            {
                var fields = template.GetFields(true);
                sections = fields.Select(f => f.Section).Distinct().ToList();
            }
            else
            {
                sections = new List <TemplateSection>(template.GetSections());
            }

            sections.Sort(this);

            foreach (var section in sections)
            {
                WriteSection(output, database, section, template, includeInheritedFields, false);
            }

            output.WriteEndElement();

            return(writer.ToString());
        }
 public void TestSetup()
 {
     this.imageBuilderTestContext = ImageBuilderTestContext.Create(this.TestContext.TestName);
     this.imageBuilder            = imageBuilderTestContext.ImageBuilder;
     this.imageStore = imageBuilderTestContext.ImageStore;
     ImageBuilderTest.CreateDropAndSetFabricCodePath();
 }
示例#24
0
        public static void RenderItem(HtmlTextWriter output, string value, string language, string controlId)
        {
            if (string.IsNullOrEmpty(value))
            {
                return;
            }
            Item         obj          = Sitecore.Context.ContentDatabase.GetItem(value, Language.Parse(language));
            ImageBuilder imageBuilder = new ImageBuilder();

            imageBuilder.Width  = 16;
            imageBuilder.Height = 16;
            imageBuilder.Margin = "0px 4px 0px 0px";
            imageBuilder.Align  = "absmiddle";
            if (obj == null)
            {
                imageBuilder.Src = "Applications/16x16/forbidden.png";
                output.Write("<div>");
                imageBuilder.Render(output);
                output.Write(Translate.Text("Item not found: {0}", (object)HttpUtility.HtmlEncode(value)));
                output.Write("</div>");
            }
            else
            {
                imageBuilder.Src = obj.Appearance.Icon;
                output.Write("<div title=\"" + obj.Paths.ContentPath + "\">");
                RenderButtons(output, value, controlId);
                imageBuilder.Render(output);
                output.Write(obj.GetUIDisplayName());
                output.Write("</div>");
            }
        }
示例#25
0
        /// <summary>
        /// 等级提升界面
        /// </summary>
        /// <param name="context"></param>
        /// <param name="character"></param>
        public LevelupScreen(SimulatorContext context, PlayerCharacter character) : base(context)
        {
            _infoImg = Context.LibData.GetImage(2, 9)[0];

            ICanvas         canvas       = Context.GraphicsFactory.NewCanvas(_infoImg);;
            ResLevelupChain levelupChain = character.LevelupChain;
            int             curl         = character.Level;

            Context.Util.DrawSmallNum(canvas, character.HP, 37, 9); character.HP = character.MaxHP;
            Context.Util.DrawSmallNum(canvas, character.MaxHP - (levelupChain.GetMaxHP(curl) - levelupChain.GetMaxHP(curl - 1)), 56, 9);
            Context.Util.DrawSmallNum(canvas, character.MaxHP, 86, 9);
            Context.Util.DrawSmallNum(canvas, character.MaxHP, 105, 9);
            Context.Util.DrawSmallNum(canvas, character.MP, 37, 21); character.MP = character.MaxMP;
            Context.Util.DrawSmallNum(canvas, character.MaxMP - (levelupChain.GetMaxMP(curl) - levelupChain.GetMaxMP(curl - 1)), 56, 21);
            Context.Util.DrawSmallNum(canvas, character.MaxMP, 86, 21);
            Context.Util.DrawSmallNum(canvas, character.MaxMP, 105, 21);
            Context.Util.DrawSmallNum(canvas, character.Attack - (levelupChain.GetAttack(curl) - levelupChain.GetAttack(curl - 1)), 47, 33);
            Context.Util.DrawSmallNum(canvas, character.Attack, 96, 33);
            Context.Util.DrawSmallNum(canvas, character.Defend - (levelupChain.GetDefend(curl) - levelupChain.GetDefend(curl - 1)), 47, 45);
            Context.Util.DrawSmallNum(canvas, character.Defend, 96, 45);
            Context.Util.DrawSmallNum(canvas, character.Speed - (levelupChain.GetSpeed(curl) - levelupChain.GetSpeed(curl - 1)), 47, 57);
            Context.Util.DrawSmallNum(canvas, character.Speed, 96, 57);
            Context.Util.DrawSmallNum(canvas, character.Lingli - (levelupChain.GetLingli(curl) - levelupChain.GetLingli(curl - 1)), 47, 69);
            Context.Util.DrawSmallNum(canvas, character.Lingli, 96, 69);
            Context.Util.DrawSmallNum(canvas, character.Luck - (levelupChain.GetLuck(curl) - levelupChain.GetLuck(curl - 1)), 47, 81);
            Context.Util.DrawSmallNum(canvas, character.Luck, 96, 81);
        }
示例#26
0
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            if (colorBox == null)
            {
                using (var ib = new ImageBuilder(size, size)) {
                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            ib.Context.Rectangle(i, j, 1, 1);
                            ib.Context.SetColor(GetColor(i, j));
                            ib.Context.Fill();
                        }
                    }

                    if (ParentWindow != null)
                    {
                        colorBox = ib.ToBitmap(this);                          // take screen scale factor into account
                    }
                    else
                    {
                        colorBox = ib.ToBitmap();
                    }
                }
            }
            ctx.DrawImage(colorBox, padding, padding);
            ctx.SetLineWidth(1);
            ctx.SetColor(Colors.Black);
            ctx.Rectangle(selection.X + padding - 2 + 0.5, selection.Y + padding - 2 + 0.5, 4, 4);
            ctx.Stroke();
        }
示例#27
0
        private static void RenderTreeNodeGlyph(HtmlTextWriter output, IDataView dataView, string filter, Item item, string id, bool isExpanded)
        {
            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(dataView, "dataView");
            Assert.ArgumentNotNull(filter, "filter");
            Assert.ArgumentNotNull(item, "item");
            Assert.ArgumentNotNullOrEmpty(id, "id");
            ImageBuilder builder2 = new ImageBuilder {
                Class = "scContentTreeNodeGlyph"
            };
            ImageBuilder builder = builder2;

            if (dataView.HasChildren(item, filter))
            {
                if (isExpanded)
                {
                    builder.Src = "images/collapse15x15.gif";
                }
                else
                {
                    builder.Src = "images/expand15x15.gif";
                }
            }
            else
            {
                builder.Src = "images/noexpand15x15.gif";
            }
            output.Write(builder.ToString());
        }
示例#28
0
        public void LogoTest()
        {
            var imgFile      = Path.Combine(Directory.GetCurrentDirectory(), IMG_FILE_PATH);
            var imageBuilder = new ImageBuilder(imgFile);

            Assert.IsTrue((bool)imageBuilder.ReadProperty(i => i.IsJpeg()));
        }
        public void SetDisplayParameters(int desiredWidth, int desiredHeight, PixelFormat colorFormat, Endianess endianess)
        {
            if (desiredWidth == 0 && desiredHeight == 0)
            {
                return;
            }

            DesiredDisplayWidth  = desiredWidth;
            DesiredDisplayHeight = desiredHeight;

            lock (imgLock)
            {
                var pixelFormat = PixelFormat.RGBA8888;
#if PLATFORM_WINDOWS
                pixelFormat = PixelFormat.BGRA8888;
#endif
                converter = PixelManipulationTools.GetConverter(colorFormat, endianess, pixelFormat, Endianess.BigEndian);
                outBuffer = new byte[desiredWidth * desiredHeight * pixelFormat.GetColorDepth()];

                img             = new ImageBuilder(DesiredDisplayWidth, DesiredDisplayHeight).ToBitmap();
                drawMethod      = CalculateDrawMethod();
                ActualImageArea = CalculateActualImageRectangle();

                anythingDrawnAfterLastReconfiguration = false;
            }

            OnDisplayParametersChanged(DesiredDisplayWidth, DesiredDisplayHeight, colorFormat);
        }
        private void AddLanguage(Language language, Set <string> addedLanguages)
        {
            if (language == null || addedLanguages.Contains(language.Name))
            {
                return;
            }

            addedLanguages.Add(language.Name);
            var control = ControlFactory.GetControl("LanguageGallery.Option") as XmlControl;

            Assert.IsNotNull(control, "Xml Control \"LanguageGallery.Option\" not found");
            Context.ClientPage.AddControl(Languages, control);

            var icon = language.GetIcon();
            //var icon = CurrentVersion.IsAtLeast(SitecoreVersion.V80) ? "Office/32x32/flag_generic.png" : "Flags/32x32/flag_generic.png";

            var builder = new ImageBuilder
            {
                Src   = Images.GetThemedImageSource(icon, ImageDimension.id16x16),
                Class = "scRibbonToolbarSmallGalleryButtonIcon",
                Alt   = language.Name
            };

            control["Class"]        = (language.Name == CurrentLanguage) ? "selected" : string.Empty;
            control["LanguageIcon"] = $"<div class=\"versionNum\">{builder}</div>";
            control["LanguageCode"] = Translate.Text("<b>{0}</b>", language.Name);
            control["Name"]         = Translate.Text("<b>{0}</b>.", language.GetDisplayName());
            control["Click"]        = $"ise:setlanguage(language={language.Name})";
        }
示例#31
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            // Create a push button to trigger a command add it to the ribbon panel.
            var thisAssembly = Assembly.GetExecutingAssembly();

            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image   = ImageBuilder.BuildImage("4");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate");
            }

            Revit.ApplicationUI.ViewActivated += ActiveUIApplication_ViewActivated;
        }
示例#32
0
        public static void CreateUI(RibbonPanel ribbonPanel)
        {
            var items = ribbonPanel.AddStackedItems
                        (
                new ComboBoxData("Category"),
                new PulldownButtonData("cmdRhinoInside.GrasshopperPlayer", "Grasshopper Player")
                        );

            categoriesComboBox = items[0] as Autodesk.Revit.UI.ComboBox;
            if (categoriesComboBox != null)
            {
                categoriesComboBox.ToolTip = "Category where Grasshopper Player will place geometry.";
            }

            mruPullDownButton = items[1] as Autodesk.Revit.UI.PulldownButton;
            if (mruPullDownButton != null)
            {
                mruPullDownButton.ToolTip    = "Loads and evals a Grasshopper definition";
                mruPullDownButton.Image      = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GrasshopperPlayer.png", true);
                mruPullDownButton.LargeImage = ImageBuilder.LoadBitmapImage("RhinoInside.Resources.GrasshopperPlayer.png");
                mruPullDownButton.SetContextualHelp(new ContextualHelp(ContextualHelpType.Url, "https://github.com/mcneel/rhino.inside/blob/master/Autodesk/Revit/README.md#sample-4"));

                mruPullDownButton.AddPushButton(typeof(Browse), "Browse...", "Browse for a Grasshopper definition to evaluate", typeof(Availability));
            }

            EventHandler <IdlingEventArgs> BuildDirectShapeCategoryList = null;

            Revit.ApplicationUI.Idling += BuildDirectShapeCategoryList = (sender, args) =>
            {
                var doc = (sender as UIApplication)?.ActiveUIDocument.Document;
                if (doc == null)
                {
                    return;
                }

                var directShapeCategories = Enum.GetValues(typeof(BuiltInCategory)).Cast <BuiltInCategory>().
                                            Where(categoryId => DirectShape.IsValidCategoryId(new ElementId(categoryId), doc)).
                                            Select(categoryId => Autodesk.Revit.DB.Category.GetCategory(doc, categoryId));

                foreach (var group in directShapeCategories.GroupBy(x => x.CategoryType).OrderBy(x => x.Key.ToString()))
                {
                    foreach (var category in group.OrderBy(x => x.Name))
                    {
                        var comboBoxMemberData = new ComboBoxMemberData(((BuiltInCategory)category.Id.IntegerValue).ToString(), category.Name)
                        {
                            GroupName = group.Key.ToString()
                        };
                        var item = categoriesComboBox.AddItem(comboBoxMemberData);

                        if ((BuiltInCategory)category.Id.IntegerValue == BuiltInCategory.OST_GenericModel)
                        {
                            categoriesComboBox.Current = item;
                        }
                    }
                }

                Revit.ApplicationUI.Idling -= BuildDirectShapeCategoryList;
            };
        }
示例#33
0
        bool AddFileToMru(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(false);
            }

            if (mruPushPuttons == null)
            {
                mruPullDownButton.AddSeparator();
                mruPushPuttons = new Type[] { typeof(Mru0), typeof(Mru1), typeof(Mru2), typeof(Mru3), typeof(Mru4), typeof(Mru5) }.
                Select(x => mruPullDownButton.AddPushButton(x)).ToArray();
                foreach (var mru in mruPushPuttons)
                {
                    mru.Visible = false;
                    mru.Enabled = false;
                }
            }

            int lastItemToMove = 0;

            for (int m = 0; m < mruPushPuttons.Length; ++m)
            {
                lastItemToMove++;

                if (mruPushPuttons[m].ToolTip == filePath)
                {
                    break;
                }
            }

            int itemsToMove = lastItemToMove - 1;

            if (itemsToMove > 0)
            {
                for (int m = lastItemToMove - 1; m > 0; --m)
                {
                    mruPushPuttons[m].Visible         = mruPushPuttons[m - 1].Visible;
                    mruPushPuttons[m].Enabled         = mruPushPuttons[m - 1].Enabled;
                    mruPushPuttons[m].ToolTipImage    = mruPushPuttons[m - 1].ToolTipImage;
                    mruPushPuttons[m].LongDescription = mruPushPuttons[m - 1].LongDescription;
                    mruPushPuttons[m].ToolTip         = mruPushPuttons[m - 1].ToolTip;
                    mruPushPuttons[m].ItemText        = mruPushPuttons[m - 1].ItemText;
                    mruPushPuttons[m].Image           = mruPushPuttons[m - 1].Image;
                    mruPushPuttons[m].LargeImage      = mruPushPuttons[m - 1].LargeImage;
                }

                mruPushPuttons[0].Visible         = true;
                mruPushPuttons[0].Enabled         = true;
                mruPushPuttons[0].ToolTipImage    = null;
                mruPushPuttons[0].LongDescription = string.Empty;
                mruPushPuttons[0].ToolTip         = filePath;
                mruPushPuttons[0].ItemText        = Path.GetFileNameWithoutExtension(filePath);
                mruPushPuttons[0].Image           = ImageBuilder.BuildImage(Path.GetExtension(filePath).Substring(1));
                mruPushPuttons[0].LargeImage      = ImageBuilder.BuildLargeImage(Path.GetExtension(filePath).Substring(1));
            }

            return(true);
        }
示例#34
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent)
            {
                CurrenSession = WebUtil.GetQueryString("currentSessionId");

                var sessions = ScriptSessionManager.GetAll();
                foreach (var session in sessions)
                {
                    var control = ControlFactory.GetControl("SessionIDGallery.Option") as XmlControl;
                    Assert.IsNotNull(control, typeof (XmlControl), "Xml Control \"{0}\" not found",
                        "Gallery.Versions.Option");
                    Context.ClientPage.AddControl(Sessions, control);

                    var icon = session.ApplianceType == ApplicationNames.AjaxConsole
                        ? "powershell/16x16/console.png"
                        : "powershell/16x16/PowerShell_Runner.png";
                    var builder = new ImageBuilder
                    {
                        Src = Images.GetThemedImageSource(icon, ImageDimension.id16x16),
                        Class = "scRibbonToolbarSmallGalleryButtonIcon",
                        Alt = session.ApplianceType
                    };
                    var type = builder.ToString();
                    if (session.ID == CurrenSession)
                    {
                        type = "<div class=\"versionNumSelected\">" + type + "</div>";
                    }
                    else
                    {
                        type = "<div class=\"versionNum\">" + type + "</div>";
                    }

                    control["Number"] = type;
                    control["SessionId"] = Translate.Text("ID: <b>{0}</b>", session.ID);
                    control["Location"] = Translate.Text("Location: <b>{0}</b>.", session.CurrentLocation);
                    control["UserName"] = Translate.Text("User: <b>{0}</b>.", session.UserName);
                    control["Click"] = string.Format("ise:setsessionid(id={0})", session.ID);
                }
                var item =
                    Sitecore.Client.CoreDatabase.GetItem(
                        "/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Sessions");
                if ((item != null) && item.HasChildren)
                {
                    var queryString = WebUtil.GetQueryString("id");
                    Options.AddFromDataSource(item, queryString, new CommandContext(item));
                }
            }
        }
示例#35
0
        public void Image()
        {
            var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tests.Resources.logo.png");

            byte[] content;
            using (var output = new MemoryStream())
            {
                resource.CopyTo(output);
                content = output.ToArray();
            }

            var media = new MediaBuilder(this.Session).WithContent(content).Build();
            media.MediaType = new MediaTypes(this.Session).Infer(media.Content);

            var image = new ImageBuilder(this.Session).WithOriginal(media).Build();

            this.Session.Derive(true);
        }
示例#36
0
        /// <summary>
        /// Renders the control.
        /// </summary>
        /// <param name="output">The output.</param>
        protected override void DoRender(HtmlTextWriter output)
        {
            Assert.ArgumentNotNull(output, "output");
            base.SetWidthAndHeightAttributes();
            string fieldGutterHtml = GetFieldGutterHtml(this.ID);
            string templateIconHtml = GetTemplateIconHtml(this.ID);

            string iD = this.ID;
            this.ID = iD + "_holder";
            output.Write("<input id=\"" + iD + "_Value\" type=\"hidden\" value=\"" + StringUtil.EscapeQuote(this.Value) + "\" />");

            output.Write("<div border=\"0\">");
            output.Write(string.Format("<div style=\"float:left;\">{0}</div>", fieldGutterHtml));
            output.Write(string.Format("<div style=\"float:left;\">{0}</div>", templateIconHtml));
            string str2 = (this.SelectOnly || this.Disabled) ? " readonly" : string.Empty;
            string str3 = this.SelectOnly ? (" onclick=\"" + Sitecore.Context.ClientPage.GetClientEvent(iD + ".Click") + "\"") : string.Empty;

            output.Write("<div style=\"float:left;width:75%;\"><table" + base.ControlAttributes + ">");
            output.Write("<tr>");
            output.Write("<td><input id=\"" + iD + "\" class=\"scComboboxEdit\" type=\"text\"" + str2 + " onmouseout=\"javascript:return false;\" onmouseover=\"javascript:return false;\" value=\"" + StringUtil.EscapeQuote(this.GetDisplayValue()) + "\"" + str3 + "/>");
            ImageBuilder builder = new ImageBuilder
            {
                Src = this.Glyph,
                Class = "scComboboxDropDown",
                Width = 13,
                Height = 0x10,
                Align = "absmiddle"
            };

            builder.Float = "right";

            if (!this.Disabled)
            {
                builder.RollOver = true;
                builder.OnClick = "javascript:return scForm.postEvent(this, event, '" + iD + ".Click')";
            }
            output.Write("</td><td>");
            output.Write(builder);
            output.Write("</td></tr></table></div></div>");
            this.ID = iD;
        }
 private void AddDelSection(string idPostfix)
 {
     ImageBuilder builder = new ImageBuilder
     {
         Src = "Applications/16x16/delete2.png",
         Width = 0x10,
         Height = 0x10,
         Style = "cursor: pointer"
     };
     Sitecore.Web.UI.HtmlControls.Literal child = new Sitecore.Web.UI.HtmlControls.Literal
     {
         Text = builder.ToString()
     };
     Border border = new Border
     {
         ID = "DelSection" + idPostfix,
         Click = "DelSection_Click"
     };
     border.Controls.Add(child);
     this.ParentControl.Controls.Add(border);
 }
示例#38
0
 private void RenderButton(HtmlTextWriter output, string icon, string click)
 {
     Assert.ArgumentNotNull(output, "output");
     Assert.ArgumentNotNull(icon, "icon");
     Assert.ArgumentNotNull(click, "click");
     ImageBuilder builder = new ImageBuilder();
     builder.Src = icon;
     builder.Width = 0x10;
     builder.Height = 0x10;
     builder.Margin = "2px";
     if (!this.ReadOnly)
     {
         builder.OnClick = click;
     }
     output.Write(builder.ToString());
 }
示例#39
0
        public ActionResult Edit(Edit model, Command? command)
        {
            if (command == Command.Cancel)
            {
                return this.RedirectToRoute("Default", new { controller = "Organisation", action = "Index" });
            }
            var organisation = (Organisation)this.AllorsSession.Instantiate(model.Id);

            var currentCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            var currentUICultureInfo = System.Threading.Thread.CurrentThread.CurrentUICulture;

            if (command == Command.Save)
            {
                if (this.ModelState.IsValid)
                {
                    organisation.Name = model.Name;
                    organisation.Description = model.Description;
                    organisation.Information = model.Information;
                    organisation.Incorporated = model.Incorporated;
                    organisation.IncorporationDate = model.IncorporationDate.HasValue ? model.IncorporationDate.Value.ToUniversalTime() : (DateTime?)null;
                    organisation.Owner = (Person)this.AllorsSession.Instantiate(model.Owner.Id);
                    organisation.Employees = model.Werknemers != null ? this.AllorsSession.Instantiate(model.Werknemers.Ids) : null;

                    if (model.Logo.PostedFile != null)
                    {
                        if (organisation.ExistLogo)
                        {
                            organisation.Logo.Delete();
                        }

                        var media = new MediaBuilder(this.AllorsSession).WithContent(model.Logo.PostedFile.GetContent()).Build();
                        var image = new ImageBuilder(this.AllorsSession).WithOriginalFilename(model.Logo.PostedFile.FileName).WithOriginal(media).Build();

                        organisation.Logo = image;
                    }

                    if (model.Images.PostedFile != null)
                    {
                        var media = new MediaBuilder(this.AllorsSession).WithContent(model.Images.PostedFile.GetContent()).Build();
                        var image = new ImageBuilder(this.AllorsSession).WithOriginalFilename(model.Images.PostedFile.FileName).WithOriginal(media).Build();

                        organisation.AddImage(image);
                    }

                    foreach (var item in model.Images.Items)
                    {
                        if (item.Delete)
                        {
                            var image = (Image)this.AllorsSession.Instantiate(item.Id);
                            image.Delete();
                        }
                    }

                    var derivationLog = this.AllorsSession.Derive();
                    if (derivationLog.HasErrors)
                    {
                        foreach (var error in derivationLog.Errors)
                        {
                            this.ModelState.AddModelError(string.Empty, error.Message);
                        }
                    }
                    else
                    {
                        this.AllorsSession.Commit();
                        this.ModelState.Clear();
                    }
                }
            }

            this.Map(model, organisation);
            return this.View(model);
        }
        protected override void OnLoad(EventArgs args)
        {
            if (!Sitecore.Context.ClientPage.IsEvent)
             {
            SetProperties();
            GridPanel gridPanel = new GridPanel();
            Controls.Add(gridPanel);
            gridPanel.Columns = 4;
            GetControlAttributes();

            foreach (string text2 in base.Attributes.Keys)
            {
               gridPanel.Attributes.Add(text2, base.Attributes[text2]);
            }

            gridPanel.Style["margin"] = "0px 0px 4px 0px";
            SetViewStateString("ID", ID);
            Sitecore.Web.UI.HtmlControls.Literal literal = new Sitecore.Web.UI.HtmlControls.Literal("All");
            literal.Class = ("scContentControlMultilistCaption");

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");
            gridPanel.SetExtensibleProperty(literal, "Row.Height", "20px");

            LiteralControl spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            literal = new Sitecore.Web.UI.HtmlControls.Literal("Selected");
            literal.Class = "scContentControlMultilistCaption";

            gridPanel.Controls.Add(literal);
            gridPanel.SetExtensibleProperty(literal, "Width", "50%");

            spacer = new LiteralControl(Images.GetSpacer(24, 1));
            gridPanel.Controls.Add(spacer);
            gridPanel.SetExtensibleProperty(spacer, "Width", "24px");

            Scrollbox scrollbox = new Scrollbox();
            scrollbox.ID = GetUniqueID("S");

            gridPanel.Controls.Add(scrollbox);
            scrollbox.Style["border"] = "3px window-inset";
            gridPanel.SetExtensibleProperty(scrollbox, "rowspan", "2");

            DataTreeview dataTreeView = new DataTreeview();
            dataTreeView.ID = ID + "_all";
            scrollbox.Controls.Add(dataTreeView);
            dataTreeView.DblClick = ID + ".Add";

            ImageBuilder builderRight = new ImageBuilder();
            builderRight.Src = "Applications/16x16/nav_right_blue.png";
            builderRight.ID = ID + "_right";
            builderRight.Width = 0x10;
            builderRight.Height = 0x10;
            builderRight.Margin = "2";
            builderRight.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Add");

            ImageBuilder builderLeft = new ImageBuilder();
            builderLeft.Src = "Applications/16x16/nav_left_blue.png";
            builderLeft.ID = ID + "_left";
            builderLeft.Width = 0x10;
            builderLeft.Height = 0x10;
            builderLeft.Margin = "2";
            builderLeft.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Remove");

            LiteralControl literalControl = new LiteralControl(builderRight.ToString() + "<br/>" + builderLeft.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");

            Sitecore.Web.UI.HtmlControls.Listbox listbox = new Listbox();
                listBox = listbox;
            gridPanel.SetExtensibleProperty(listbox, "VAlign", "top");
            gridPanel.SetExtensibleProperty(listbox, "Height", "100%");

            gridPanel.Controls.Add(listbox);
            listbox.ID = ID + "_selected";
            listbox.DblClick = ID + ".Remove";
            listbox.Style["width"] = "100%";
            listbox.Size = "10";
            listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            dataTreeView.Disabled = ReadOnly;
            listbox.Disabled = ReadOnly;

            ImageBuilder builderUp = new ImageBuilder();
            builderUp.Src = "Applications/16x16/nav_up_blue.png";
            builderUp.ID = ID + "_up";
            builderUp.Width = 0x10;
            builderUp.Height = 0x10;
            builderUp.Margin = "2px";
            builderUp.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Up");

            ImageBuilder builderDown = new ImageBuilder();
            builderDown.Src = "Applications/16x16/nav_down_blue.png";
            builderDown.ID = ID + "_down";
            builderDown.Width = 0x10;
            builderDown.Height = 0x10;
            builderDown.Margin = "2";
            builderDown.OnClick = Sitecore.Context.ClientPage.GetClientEvent(ID + ".Down");

            literalControl = new LiteralControl(builderUp.ToString() + "<br/>" + builderDown.ToString());
            gridPanel.Controls.Add(literalControl);
            gridPanel.SetExtensibleProperty(literalControl, "Width", "30");
            gridPanel.SetExtensibleProperty(literalControl, "Align", "center");
            gridPanel.SetExtensibleProperty(literalControl, "VAlign", "top");
            gridPanel.SetExtensibleProperty(literalControl, "rowspan", "2");
            gridPanel.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));

            DataContext treeContext = new DataContext();
            gridPanel.Controls.Add(treeContext);
            treeContext.ID = GetUniqueID("D");
            treeContext.Filter = FormTemplateFilterForDisplay();
            dataTreeView.DataContext = treeContext.ID;
            treeContext.DataViewName = "Master";
            if (!string.IsNullOrEmpty(this.SourceDatabaseName))
            {
               treeContext.Parameters = "databasename=" + this.SourceDatabaseName;
            }
            treeContext.Root = DataSource;
            dataTreeView.EnableEvents();

            listbox.Size = "10";
            gridPanel.Fixed = true;
            dataTreeView.AutoUpdateDataContext = true;
            dataTreeView.ShowRoot = true;
            listbox.Attributes["class"] = "scContentControlMultilistBox";

            gridPanel.SetExtensibleProperty(scrollbox, "Height", "100%");
            RestoreState();
             }
             base.OnLoad(args);
        }
示例#41
0
        /// <summary>
        /// Render Buttons
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <param name="icon">
        /// The icon.
        /// </param>
        /// <param name="click">
        /// The click.
        /// </param>
        private void RenderButton(HtmlTextWriter output, string icon, string click)
        {
            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(icon, "icon");
            Assert.ArgumentNotNull(click, "click");
            var builder = new ImageBuilder
                              {
                                  Src = icon,
                                  Width = 0x10,
                                  Height = 0x10,
                                  Margin = "2px",
                                  ID = icon.Contains("right") ? "btnRight" + ClientID : "btnLeft" + ClientID
                              };

            if (!this.ReadOnly)
            {
                builder.OnClick = click;
            }

            output.Write(builder.ToString());
        }
 private void RenderItems(HtmlTextWriter output)
 {
     Assert.ArgumentNotNull(output, "output");
     foreach (string str in this.Value.Split(new char[] { '|' }))
     {
         if (!string.IsNullOrEmpty(str))
         {
             Item item = this.Database.GetItem(str);
             ImageBuilder builder = new ImageBuilder
             {
                 Width = 0x80,
                 Height = 0x80,
                 Margin = "0px 4px 0px 0px",
                 Align = "left"
             };
             if (item == null)
             {
                 builder.Src = "Applications/16x16/forbidden.png";
                 output.Write("<div>");
                 builder.Render(output);
                 output.Write(Translate.Text("Item not found: {0}", new object[] { str }));
                 output.Write("</div>");
             }
             else
             {
                 builder.Src = item.Appearance.Icon;
                 output.Write("<div title=\"" + item.Paths.ContentPath + "\">");
                 builder.Render(output);
                 //output.Write(item.DisplayName);
                 output.Write("</div>");
             }
         }
     }
 }
 public void RenderSectionBegin(Control parent, string controlId, string sectionName, string displayName, string icon,
     bool isCollapsed, bool renderFields)
 {
     Assert.ArgumentNotNull(parent, "parent");
     Assert.ArgumentNotNullOrEmpty(controlId, "controlId");
     Assert.ArgumentNotNullOrEmpty(sectionName, "sectionName");
     Assert.ArgumentNotNullOrEmpty(displayName, "displayName");
     Assert.ArgumentNotNull(icon, "icon");
     HtmlTextWriter writer = new HtmlTextWriter(new StringWriter(new StringBuilder(0x400)));
     if (this.Arguments.ShowSections)
     {
         string str2;
         string str = isCollapsed ? "scEditorSectionCaptionCollapsed" : "scEditorSectionCaptionExpanded";
         if (UserOptions.ContentEditor.RenderCollapsedSections)
         {
             str2 = "javascript:scContent.toggleSection('" + controlId + "','" + sectionName + "')";
         }
         else
         {
             str2 = "javascript:return scForm.postRequest('','','','" +
                    StringUtil.EscapeQuote("ToggleSection(\"" + sectionName + "\",\"" + (isCollapsed ? "1" : "0") + "\")") +
                    "')";
         }
         writer.Write("<div id=\"{0}\" class=\"{1}\" ondblclick=\"" + str2 + "\">", controlId, str);
         ImageBuilder builder2 = new ImageBuilder
                                     {
                                         ID = controlId + "_Glyph",
                                         Src = isCollapsed ? "Images/expand15x15.gif" : "Images/collapse15x15.gif",
                                         Class = "scEditorSectionCaptionGlyph",
                                         OnClick = str2
                                     };
         ImageBuilder builder = builder2;
         writer.Write(builder.ToString());
         writer.Write(
             new ImageBuilder
                 {Src = Images.GetThemedImageSource(icon, ImageDimension.id16x16), Class = "scEditorSectionCaptionIcon"}.ToString());
         writer.Write(Translate.Text(displayName));
         writer.Write("</div>");
     }
     if (renderFields || !isCollapsed)
     {
         string str3 = (isCollapsed && this.Arguments.ShowSections) ? " style=\"display:none\"" : string.Empty;
         string str4 = this.Arguments.ShowSections ? "scEditorSectionPanelCell" : "scEditorSectionPanelCell_NoSections";
         writer.Write("<table width=\"100%\" class=\"scEditorSectionPanel\"{0}><tr><td class=\"{1}\">", str3, str4);
     }
     this.AddLiteralControl(parent, writer.InnerWriter.ToString());
 }
示例#44
0
        private void RenderRecent(Item scriptItem)
        {
            if (scriptItem == null)
            {
                return;
            }
            var control = ControlFactory.GetControl("MruGallery.SearchItem") as XmlControl;
            Assert.IsNotNull(control, typeof (XmlControl), "Xml Control \"{0}\" not found",
                "MruGallery.SearchItem");

            Context.ClientPage.AddControl(Scripts, control);

            var iconUrl = scriptItem.Appearance.Icon;
            if (!string.IsNullOrWhiteSpace(iconUrl))
            {
                var builder = new ImageBuilder
                {
                    Src = Images.GetThemedImageSource(iconUrl, ImageDimension.id16x16),
                    Class = "scRibbonToolbarSmallGalleryButtonIcon",
                    Alt = scriptItem.DisplayName
                };
                iconUrl = builder.ToString();
            }

            var currentScript = ItemFromQueryString != null && ItemFromQueryString.ID == scriptItem.ID &&
                                ItemFromQueryString.Database.Name == scriptItem.Database.Name;

            control["ScriptIcon"] = "<div class=\"versionNum\">" + iconUrl + "</div>";
            control["Location"] = scriptItem.Paths.ParentPath.Substring(ApplicationSettings.ScriptLibraryPath.Length);
            control["Database"] = scriptItem.Database.Name;
            control["Name"] = scriptItem.DisplayName;
            control["Click"] = string.Format("ExecuteMruItem(\"ise:mruopen(id={0},db={1})\")", scriptItem.ID,
                scriptItem.Database.Name);
            control["Class"] = currentScript ? "selected" : string.Empty;
        }
 private void RenderButtons()
 {
     string text = string.Empty;
     string queryString = WebUtil.GetQueryString("mo");
     if (WebUtil.GetQueryString("wb") != "0")
     {
         if ((queryString != "template") && (queryString != "templateworkspace"))
         {
             text = text + new ImageBuilder { ID = "SwitchMenu", Src = "Images/Window Management/Switch_blue.png", Alt = Sitecore.Globalization.Translate.Text("Change Application."), Class = "scWindowManagementButton", OnClick = @"javascript:return scForm.postEvent(this,event,'javascript:scForm.postEvent(this,evt,\'SwitchMenu_Click\')')", RollOver = true }.ToString();
         }
         if (((queryString != "preview") && (queryString != "popup")) && (!State.Client.UsesBrowserWindows && (WebUtil.GetQueryString("il") != "1")))
         {
             ImageBuilder builder2 = new ImageBuilder
             {
                 Src = "Images/Window Management/Minimize.png",
                 Alt = Sitecore.Globalization.Translate.Text("Minimize"),
                 Class = "scWindowManagementButton",
                 OnClick = "javascript:return scForm.postEvent(this,event, 'javascript:scWin.minimizeWindow()')",
                 RollOver = true
             };
             text = text + builder2.ToString();
             builder2 = new ImageBuilder
             {
                 Src = "Images/Window Management/Maximize.png",
                 Alt = Sitecore.Globalization.Translate.Text("Maximize/Restore"),
                 Class = "scWindowManagementButton",
                 OnClick = "javascript:return scForm.postEvent(this,event,'javascript:scWin.maximizeWindow()')",
                 RollOver = true
             };
             text = text + builder2.ToString();
             text = text + new ImageBuilder { Src = "Images/Window Management/Close_red.png", Alt = Sitecore.Globalization.Translate.Text("Close"), Class = "scWindowManagementCloseButton", Width = 0x26, OnClick = "javascript:return scForm.postEvent(this,event,'javascript:scWin.closeWindow()')", RollOver = true }.ToString();
         }
         this.WindowButtonsPlaceholder.Controls.Add(new LiteralControl(text));
     }
 }
 protected void RenderButton(HtmlTextWriter output, string icon, string click)
 {
     Assert.ArgumentNotNull(output, "output");
     Assert.ArgumentNotNull(icon, "icon");
     Assert.ArgumentNotNull(click, "click");
     ImageBuilder builder = new ImageBuilder
     {
         Src = icon,
         Width = 0x10,
         Height = 0x10,
         Margin = "2px"
     };
     if (!ReadOnly)
     {
         builder.OnClick = click;
     }
     output.Write(builder.ToString());
 }
        /// <summary>
        /// Creates markup for a tool button.
        /// </summary>
        /// <param name="output"></param>
        /// <param name="icon"></param>
        /// <param name="click"></param>
        private void RenderButton(HtmlTextWriter output, string icon, string click)
        {
            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(icon, "icon");
            Assert.ArgumentNotNull(click, "click");
            var imageBuilder = new ImageBuilder
            {
                Src = icon,
                Width = 16,
                Height = 16,
                Margin = "2px",
                OnClick = click
            };

            output.Write(imageBuilder.ToString());
        }
示例#48
0
 private static void RenderTreeNodeIcon(HtmlTextWriter output, Item item)
 {
     Assert.ArgumentNotNull(output, "output");
     Assert.ArgumentNotNull(item, "item");
     ImageBuilder builder2 = new ImageBuilder {
         Src = item.Appearance.Icon,
         Width = 0x10,
         Height = 0x10,
         Class = "scContentTreeNodeIcon"
     };
     ImageBuilder builder = builder2;
     if (!string.IsNullOrEmpty(item.Help.Text))
     {
         builder.Alt = item.Help.Text;
     }
     builder.Render(output);
 }
示例#49
0
 private static void RenderTreeNodeGlyph(HtmlTextWriter output, IDataView dataView, string filter, Item item, string id, bool isExpanded)
 {
     Assert.ArgumentNotNull(output, "output");
     Assert.ArgumentNotNull(dataView, "dataView");
     Assert.ArgumentNotNull(filter, "filter");
     Assert.ArgumentNotNull(item, "item");
     Assert.ArgumentNotNullOrEmpty(id, "id");
     ImageBuilder builder2 = new ImageBuilder {
         Class = "scContentTreeNodeGlyph"
     };
     ImageBuilder builder = builder2;
     if (dataView.HasChildren(item, filter))
     {
         if (isExpanded)
         {
             builder.Src = "images/collapse15x15.gif";
         }
         else
         {
             builder.Src = "images/expand15x15.gif";
         }
     }
     else
     {
         builder.Src = "images/noexpand15x15.gif";
     }
     output.Write(builder.ToString());
 }
		// This method is the only method that differs from Sitecore's
		// TreeList class
		protected override void OnLoad(EventArgs args)
		{
			Assert.ArgumentNotNull(args, "args");
			if (!Sitecore.Context.ClientPage.IsEvent)
			{
				Database contentDatabase = Sitecore.Context.ContentDatabase;
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					contentDatabase = Factory.GetDatabase(this.DatabaseName);
				}

				this.SetProperties();
				GridPanel child = new GridPanel();
				this.Controls.Add(child);
				child.Columns = 4;
				this.GetControlAttributes();
				foreach (string str in base.Attributes.Keys)
				{
					child.Attributes.Add(str, base.Attributes[str]);
				}
				child.Style["margin"] = "0px 0px 4px 0px";
				base.SetViewStateString("ID", this.ID);
				Literal literal = new Literal("All");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				child.SetExtensibleProperty(literal, "Row.Height", "20px");
				LiteralControl control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				literal = new Literal("Selected");
				literal.Class = "scContentControlMultilistCaption";
				child.Controls.Add(literal);
				child.SetExtensibleProperty(literal, "Width", "50%");
				control = new LiteralControl(Images.GetSpacer(0x18, 1));
				child.Controls.Add(control);
				child.SetExtensibleProperty(control, "Width", "24px");
				Scrollbox scrollbox = new Scrollbox();
				scrollbox.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("S");
				child.Controls.Add(scrollbox);
				if (!UIUtil.IsIE())
				{
					scrollbox.Padding = "0px";
				}
				scrollbox.Style["border"] = "3px window-inset";
				child.SetExtensibleProperty(scrollbox, "rowspan", "2");
				child.SetExtensibleProperty(scrollbox, "VAlign", "top");
				// Instantiate the MultiTreeview rather than TreeviewEx
				MultiRootTreeview ex = new MultiRootTreeview();
				// Set the ParentItem of the treeview to the current item
				// This allows the treeview to have a 'context' of where 
				// we currently are in the content tree
				Item parentItem = contentDatabase.GetItem(ItemID);
				ex.ParentItem = parentItem;
				ex.ID = this.ID + "_all";
				if (!string.IsNullOrEmpty(AncestorTemplateDatasource))
				{
					Item parent = parentItem;
					while (parent != null && String.Compare(parent.TemplateID.ToString(), AncestorTemplateDatasource, StringComparison.OrdinalIgnoreCase) != 0)
					{
						parent = parent.Parent;
					}
					ex.MultiTrees.Add(2, parent);
				}
				else if (DataSources.Count > 0)
				{
					foreach (KeyValuePair<int, string> kvp in DataSources)
					{
						if (!string.IsNullOrEmpty(kvp.Value))
						{
							if (kvp.Value == ".")
							{
								ex.MultiTrees.Add(kvp.Key, parentItem);
							}
							else if (kvp.Value.StartsWith("."))
							{
								string path = kvp.Value.Replace(".", parentItem.Paths.FullPath);
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(path));
							}
							else
							{
								ex.MultiTrees.Add(kvp.Key, contentDatabase.GetItem(kvp.Value));
							}
						}
					}
				}
				scrollbox.Controls.Add(ex);
				ex.DblClick = this.ID + ".Add";
				ex.AllowDragging = false;
				ImageBuilder builder = new ImageBuilder();
				builder.Src = "Applications/16x16/nav_right_blue.png";
				builder.ID = this.ID + "_right";
				builder.Width = 0x10;
				builder.Height = 0x10;
				builder.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Add");
				ImageBuilder builder2 = new ImageBuilder();
				builder2.Src = "Applications/16x16/nav_left_blue.png";
				builder2.ID = this.ID + "_left";
				builder2.Width = 0x10;
				builder2.Height = 0x10;
				builder2.Margin = UIUtil.IsIE() ? "2px" : "2px 0px 2px 2px";
				builder2.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Remove");
				LiteralControl control2 = new LiteralControl(builder + "<br/>" + builder2);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				Listbox listbox = new Listbox();
				child.Controls.Add(listbox);
				child.SetExtensibleProperty(listbox, "VAlign", "top");
				child.SetExtensibleProperty(listbox, "Height", "100%");
				this._listBox = listbox;
				listbox.ID = this.ID + "_selected";
				listbox.DblClick = this.ID + ".Remove";
				listbox.Style["width"] = "100%";
				listbox.Size = "10";
				listbox.Attributes["onchange"] = "javascript:document.getElementById('" + this.ID + "_help').innerHTML=this.selectedIndex>=0?this.options[this.selectedIndex].innerHTML:''";
				listbox.Attributes["class"] = "scContentControlMultilistBox";
				ex.Enabled = !this.ReadOnly;
				listbox.Disabled = this.ReadOnly;
				ImageBuilder builder3 = new ImageBuilder();
				builder3.Src = "Applications/16x16/nav_up_blue.png";
				builder3.ID = this.ID + "_up";
				builder3.Width = 0x10;
				builder3.Height = 0x10;
				builder3.Margin = "2px";
				builder3.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Up");
				ImageBuilder builder4 = new ImageBuilder();
				builder4.Src = "Applications/16x16/nav_down_blue.png";
				builder4.ID = this.ID + "_down";
				builder4.Width = 0x10;
				builder4.Height = 0x10;
				builder4.Margin = "2px";
				builder4.OnClick = Sitecore.Context.ClientPage.GetClientEvent(this.ID + ".Down");
				control2 = new LiteralControl(builder3 + "<br/>" + builder4);
				child.Controls.Add(control2);
				child.SetExtensibleProperty(control2, "Width", "30");
				child.SetExtensibleProperty(control2, "Align", "center");
				child.SetExtensibleProperty(control2, "VAlign", "top");
				child.SetExtensibleProperty(control2, "rowspan", "2");
				child.Controls.Add(new LiteralControl("<div style=\"border:1px solid #999999;font:8pt tahoma;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + this.ID + "_help\"></div>"));
				DataContext context = new DataContext();
				child.Controls.Add(context);
				context.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("D");
				context.Filter = this.FormTemplateFilterForDisplay();
				ex.DataContext = context.ID;
				context.DataViewName = "Master";
				if (!string.IsNullOrEmpty(this.DatabaseName))
				{
					context.Parameters = "databasename=" + this.DatabaseName;
				}
				context.Root = this.DataSource;
				child.Fixed = true;
				ex.ShowRoot = true;
				child.SetExtensibleProperty(scrollbox, "Height", "100%");
				this.RestoreState();
			}
			base.OnLoad(args);
		}