public override void Build() { if (Chunk.Type > MessageType.SerializedObject) { SerializedObject = ViewContent.Session.GetCachedObject(Chunk.SequenceNumber, Chunk.GetSerializedObject); } Fragment fragment; double height; if (Chunk.Type == MessageType.ConnectionBanner && ViewContent.Session.ConnectionBanner != null) { // show connection info instead "Connecting to ..." fragment = new ConnectionFragment() { Model = ViewContent.Session.ConnectionBanner }; height = 76; } else if (Chunk.Type == MessageType.SslHandshake) { fragment = new SslHandshakeFragment() { Model = (SslHandshake)SerializedObject }; height = 45; } else { fragment = new MessageFragment(); height = 56; } ViewContent.MoveInsertionPointToLineBeginning(); fragment.Source = this; fragment.Bounds = new Rect(0, ViewContent.InsertionPoint.Y, ViewContent.Metrics.Viewport.Width, ViewContent.SnapToPixelsY(height)); fragment.ApproxFileOffset = Chunk.ActualOffset; fragment.ApproxFileLength = Chunk.ActualLength; ViewContent.TextLayer.Add(fragment); ViewContent.MoveInsertionPointToLineBeginning(); }
protected override bool SetViewContentInternal(ViewContentType contentType, ViewNode target, object content) { FrameworkElement frameworkElement = (FrameworkElement)null; object obj = content; bool flag = false; if (contentType == ViewContentType.Content) { if (this.currentScopedInstance == content && this.currentContentType == ViewContentType.Content) { this.UpdateViewContentIfNecessary(false); return(false); } if (target != null && content != null) { ViewContent viewContent = this.ProvideViewContent(target, content); contentType = viewContent.ViewContentType; content = viewContent.Content; flag = viewContent.IsSizeFixed; frameworkElement = content as FrameworkElement; } else { contentType = ViewContentType.DefaultMessage; } if (this.currentScopedInstance == null && content == null && this.currentContentType == ViewContentType.DefaultMessage) { return(false); } } if (contentType == ViewContentType.Content) { this.currentScopedInstance = obj; } else { this.currentScopedInstance = (object)null; frameworkElement = (FrameworkElement)null; } this.currentContentType = contentType; this.ClearAdornerSets(); if (flag && contentType == ViewContentType.Content && (!double.IsNaN(frameworkElement.Width) && !double.IsNaN(frameworkElement.Height)) || this.ViewModel.PreferredSize == Size.Empty) { this.Artboard.ContentArea.MinWidth = 20.0; this.Artboard.ContentArea.MinHeight = 20.0; } else { this.Artboard.ContentArea.MinWidth = this.ViewModel.PreferredSize.Width; this.Artboard.ContentArea.MinHeight = this.ViewModel.PreferredSize.Height; } if (frameworkElement != null) { this.Artboard.EditableContent = (FrameworkElement)null; this.SetApplicationResourceDictionary((ResourceDictionary)null); this.Artboard.EditableContent = frameworkElement; } else { this.Artboard.SafelyRemoveEditableContent(); } this.Artboard.ContentArea.SetValue(TextElement.FontFamilyProperty, TextElement.FontFamilyProperty.DefaultMetadata.DefaultValue); this.Artboard.ContentArea.SetValue(TextElement.FontSizeProperty, TextElement.FontSizeProperty.DefaultMetadata.DefaultValue); switch (contentType) { case ViewContentType.DefaultMessage: this.IsDefaultMessageDisplayed = true; this.MessageContent = (object)null; break; case ViewContentType.Content: this.IsDefaultMessageDisplayed = false; this.MessageContent = (object)null; NameScope.SetNameScope((DependencyObject)frameworkElement, this.rootNameScope); break; default: this.IsDefaultMessageDisplayed = false; this.MessageContent = content; break; } return(true); }
public MacEditorView(ViewContent content) : base(content) { }
protected void Page_Load(object sender, EventArgs e) { if (!WebUtil.CheckPrivilege(WebConfig.FunctionGameInfoStatisticAdvancedStatistic, OpType.READ, Session)) { Response.Redirect(WebConfig.PageNotEnoughPrivilege, true); } if (!IsPostBack) { ClearAllCacheData(); ServerDropDownList.CreateServerList(ServerGroupDropDownList.SelectedServerGroup); StartDate.SelectedDate = DateTime.Today.AddMonths(-1); EndDate.SelectedDate = DateTime.Now; foreach (string itemCountType in ItemCountTypes) { ListItem item = new ListItem(itemCountType); item.Selected = true; CheckBoxListShowItemCount.Items.Add(item); } foreach (string questCountType in QuestCountTypes) { ListItem item = new ListItem(questCountType); item.Selected = true; CheckBoxListShowQuestCount.Items.Add(item); } } try { _viewContent = (ViewContent)int.Parse(ListBoxViewContent.SelectedValue); _viewType = (ViewType)int.Parse(ListBoxViewType.SelectedValue); _chartType = (ChartType)int.Parse(ListBoxChartType.SelectedValue); } catch (Exception) { _viewContent = ViewContent.Exp; _viewType = ViewType.ByMonth; _chartType = ChartType.Bar; } LabelOpMsg.Text = string.Empty; ZedGraphWebExpStatistic.Visible = false; }
private bool SetViewContentWorker(ViewContentType contentType, ViewNode target, object content) { object obj = content; if (contentType == ViewContentType.Content) { if (!this.isRootInstanceKnownInvalid && this.postponedUpdate == SceneView.PostponedUpdate.None && (this.currentScopedInstance == content && this.currentContentType == ViewContentType.Content)) { this.ApplyNameScope(this.rootNameScope as SilverlightNameScope); this.UpdateViewContentIfNecessary(false); return(false); } if (content != null) { ViewContent viewContent = this.ProvideViewContent(target, content); contentType = viewContent.ViewContentType; content = viewContent.Content; if (content != null && contentType == ViewContentType.Content && !this.Document.ProjectContext.ResolveType(PlatformTypes.FrameworkElement).RuntimeType.IsAssignableFrom(content.GetType())) { contentType = ViewContentType.DefaultMessage; } } else { contentType = ViewContentType.DefaultMessage; } if (!this.isRootInstanceKnownInvalid && this.currentScopedInstance == null && (content == null && this.currentContentType == ViewContentType.DefaultMessage)) { return(false); } } ViewContentType viewContentType = this.currentContentType; this.currentContentType = contentType; if (contentType == ViewContentType.Content) { this.currentScopedInstance = obj; this.imageHost.RootInstance = content; this.hitTestRoot = this.Platform.ViewObjectFactory.Instantiate(this.imageHost.HitTestRoot) as IViewVisual; if (this.currentContentType != contentType) { return(true); } this.isRootInstanceKnownInvalid = false; if (viewContentType != ViewContentType.Content) { this.imageHost.Redraw(true); } this.UpdateRootBounds(); this.UpdateLayout(); this.disposedExceptionCaught = false; this.catastrohpicFailureCaught = false; } else { this.imageHost.RootInstance = (object)null; this.currentScopedInstance = (object)null; } this.ClearAdornerSets(); bool flag = false; if (contentType == ViewContentType.Content) { ReferenceStep referenceStep1 = this.ProjectContext.ResolveProperty(BaseFrameworkElement.ActualWidthProperty) as ReferenceStep; ReferenceStep referenceStep2 = this.ProjectContext.ResolveProperty(BaseFrameworkElement.ActualHeightProperty) as ReferenceStep; double num1 = (double)referenceStep1.GetValue(content); double num2 = (double)referenceStep2.GetValue(content); if (!double.IsNaN(num1) && !double.IsNaN(num2)) { this.SetContentSize(new Size(num1, num2)); flag = true; } } if (!flag) { if (this.ViewModel.PreferredSize != Size.Empty) { this.SetContentSize(new Size(this.ViewModel.PreferredSize.Width, this.ViewModel.PreferredSize.Height)); } else { this.SetContentSize(new Size(20.0, 20.0)); } } switch (contentType) { case ViewContentType.DefaultMessage: this.IsDefaultMessageDisplayed = true; this.MessageContent = (object)null; break; case ViewContentType.Content: this.IsDefaultMessageDisplayed = false; this.MessageContent = (object)null; this.ApplyNameScope(this.rootNameScope as SilverlightNameScope); break; default: this.IsDefaultMessageDisplayed = false; this.MessageContent = content; break; } return(true); }
public ActionGroupView(ViewContent content, Stetic.ActionGroupInfo group, GuiBuilderProject project) : base(content) { groupName = group.Name; this.project = project; LoadDesigner(); }
/// <summary> /// 发布模型 /// </summary> /// <param name="modelId"></param> /// <returns></returns> internal bool PublishModel(int modelId) { ViewModel model = this.GetModelInfo(modelId); if (model == null) { return(this.FaildMessage("模型错误")); } Language[] languages = SettingAgent.Instance().GetSetting(SystemSetting.SettingType.Language).Split(',').Select(t => t.ToEnum <Language>()).ToArray(); if (languages.Length == 0) { return(this.FaildMessage("没有配置语言包")); } string translateUrl = SettingAgent.Instance().GetSetting(SystemSetting.SettingType.Translate); if (string.IsNullOrEmpty(translateUrl)) { return(this.FaildMessage("没有配置语言包接口地址")); } //#1 找出样式文件中需要替换的资源路径 model.Style = Regex.Replace(model.Style, @"url\((?<Resource>[^\)]+?)\)", t => { string resource = t.Groups["Resource"].Value; if (model.ResourceFiles.ContainsKey(resource)) { return($"url({model.ResourceFiles[resource]})"); } return(t.Value); }); using (DbExecutor db = NewExecutor()) { model.Update(db, t => t.Style); } //#2 发布页面的各个语言版本 { Regex regex = new Regex(@"~.+?~", RegexOptions.Multiline); //#2.1 找出单词 Dictionary <string, bool> words = new Dictionary <string, bool>(); foreach (Match match in regex.Matches(model.Page)) { string word = match.Value; if (!words.ContainsKey(word)) { words.Add(word, true); } } //#2.2 发送到翻译API,获得语言包 Dictionary <string, Dictionary <Language, string> > dic = Translate.Get(words.Select(t => t.Key).ToArray(), translateUrl, languages); foreach (Language language in languages) { int total = 0; int count = 0; string content = regex.Replace(model.Page, t => { total++; if (dic.ContainsKey(t.Value) && dic[t.Value].ContainsKey(language)) { count++; return(dic[t.Value][language]); } return(t.Value.Replace("~", string.Empty)); }); string path = $"html/{ Encryption.toMD5Short(Encryption.toMD5(content)) }.html"; if (!OSSAgent.Upload(new OSSSetting(SettingAgent.Instance().GetSetting(SystemSetting.SettingType.CDNOSS)), path, Encoding.UTF8.GetBytes(content), new ObjectMetadata() { ContentType = "text/html", ContentEncoding = "utf-8", ContentDisposition = "inline", CacheControl = "only-if-cached", ExpirationTime = DateTime.Now.AddYears(1), }, out string message)) { return(this.FaildMessage(message)); } ViewContent viewContent = new ViewContent() { Language = language, ModelID = modelId, Path = path, Translate = total == 0 ? 1M : count / (decimal)total }; this.SaveModelContent(viewContent); } } return(true); }
public DirtyFilesDialog(IReadOnlyList <Document> docs, bool closeWorkspace, bool groupByProject) : base(GettextCatalog.GetString("Save Files"), IdeApp.Workbench.RootWindow, DialogFlags.Modal) { tsFiles = new TreeStore(typeof(string), typeof(bool), typeof(SdiWorkspaceWindow), typeof(bool)); tvFiles = new TreeView(tsFiles); TreeIter topCombineIter = TreeIter.Zero; Hashtable projectIters = new Hashtable(); foreach (Document doc in docs) { if (!doc.IsDirty) { continue; } ViewContent viewcontent = doc.Window.ViewContent; if (groupByProject && viewcontent.Project != null) { TreeIter projIter = TreeIter.Zero; if (projectIters.ContainsKey(viewcontent.Project)) { projIter = (TreeIter)projectIters [viewcontent.Project]; } else { if (topCombineIter.Equals(TreeIter.Zero)) { projIter = tsFiles.AppendValues(GettextCatalog.GetString("Project: {0}", viewcontent.Project.Name), true, null, false); } else { projIter = tsFiles.AppendValues(topCombineIter, GettextCatalog.GetString("Project: {0}", viewcontent.Project.Name), true, null, false); } projectIters [viewcontent.Project] = projIter; } tsFiles.AppendValues(projIter, viewcontent.PathRelativeToProject, true, viewcontent.WorkbenchWindow); } else { if (viewcontent.ContentName == null) { viewcontent.ContentName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), viewcontent.UntitledName); } tsFiles.AppendValues(viewcontent.ContentName, true, viewcontent.WorkbenchWindow); } } if (!topCombineIter.Equals(TreeIter.Zero)) { if (!tsFiles.IterHasChild(topCombineIter)) { tsFiles.Remove(ref topCombineIter); } } TreeViewColumn mainColumn = new TreeViewColumn(); mainColumn.Title = "header"; togRender = new CellRendererToggle(); togRender.Toggled += toggled; mainColumn.PackStart(togRender, false); mainColumn.AddAttribute(togRender, "active", 1); mainColumn.AddAttribute(togRender, "inconsistent", 3); textRender = new CellRendererText(); mainColumn.PackStart(textRender, true); mainColumn.AddAttribute(textRender, "text", 0); tvFiles.AppendColumn(mainColumn); tvFiles.HeadersVisible = false; tvFiles.ExpandAll(); ScrolledWindow sc = new ScrolledWindow(); sc.Add(tvFiles); sc.ShadowType = ShadowType.In; sc.BorderWidth = 6; this.VBox.PackStart(sc, true, true, 6); btnSaveAndQuit = new Button(closeWorkspace ? GettextCatalog.GetString("_Save and Quit") : GettextCatalog.GetString("_Save and Close")); btnQuit = new Button(closeWorkspace ? Gtk.Stock.Quit : Gtk.Stock.Close); btnCancel = new Button(Gtk.Stock.Cancel); btnSaveAndQuit.Clicked += SaveAndQuit; btnQuit.Clicked += Quit; btnCancel.Clicked += Cancel; this.ActionArea.PackStart(btnCancel); this.ActionArea.PackStart(btnQuit); this.ActionArea.PackStart(btnSaveAndQuit); this.SetDefaultSize(300, 200); this.Child.ShowAll(); }