private static CaptionElement MapToCaption(PElement pElement, RegionElement region) { var captionElement = BuildTimedTextElements(pElement, region); captionElement.Id = pElement.Id ?? Guid.NewGuid().ToString(); return(captionElement as CaptionElement); }
static void Main(string[] args) { var div = new DivElement(); var paragraph = new PElement(); var br = new BrElement(); var text = new TextElement("Example text"); var image = new ImageElement(); image.SetAttribute("src", "http://opensourceforu.com/wp-content/uploads/2016/03/Microsoft.png"); paragraph.Add(text); paragraph.Add(br); div.Add(image); div.Add(paragraph); Console.WriteLine("Render div:"); Console.Write(div.Render()); Console.WriteLine("Render paragraph:"); Console.Write(paragraph.Render()); Console.WriteLine("It works"); }
public void Refresh() { if(DataContext==null || !(DataContext is PElement)) return; PElement el = (PElement)DataContext; if (el.Equals(element)) { return; } if (el.State > 6) { //filterDisabled.Visibility = Windows.UI.Xaml.Visibility.Visible; LayoutRoot.Opacity = 0.2; } else { //filterDisabled.Visibility = Windows.UI.Xaml.Visibility.Collapsed; LayoutRoot.Opacity = 1; } filterDisabled.Visibility = Windows.UI.Xaml.Visibility.Collapsed; int max = el.Graph.Limit56; if (el.Value > max) max = (int)el.Value; max = (int)(max * 1.1); vpp = max / Height; e1.Height = (int)(el.Graph.Limit12 / vpp); e2.Height = (int)((el.Graph.Limit23 - el.Graph.Limit12) / vpp); e3.Height = (int)((el.Graph.Limit34 - el.Graph.Limit23) / vpp); e4.Height = (int)((el.Graph.Limit45 - el.Graph.Limit34) / vpp); e5.Height = (int)((el.Graph.Limit56 - el.Graph.Limit45) / vpp); e6.Height = Height - e1.Height - e2.Height - e3.Height - e4.Height - e5.Height; //e6.Height = (int)((max - el.Graph.Limit56) / vpp); filter.Height = Height; filterDisabled.Height = Height+3; l12.Text = el.Graph.Limit12.ToString(); l23.Text = el.Graph.Limit23.ToString(); l34.Text = el.Graph.Limit34.ToString(); l45.Text = el.Graph.Limit45.ToString(); l56.Text = el.Graph.Limit56.ToString(); int topOffset; if (Height < 200) { l12.FontSize = 7; l23.FontSize = 7; l34.FontSize = 7; l45.FontSize = 7; l56.FontSize = 7; topOffset = 3; } else { topOffset = 0; } Canvas.SetTop(l12, 3+e2.Height + e3.Height + e4.Height + e5.Height + e6.Height + topOffset); Canvas.SetTop(l23, e3.Height + e4.Height + e5.Height + e6.Height + topOffset); Canvas.SetTop(l34, e4.Height + e5.Height + e6.Height + topOffset); Canvas.SetTop(l45, e5.Height + e6.Height + topOffset); Canvas.SetTop(l56, e6.Height + topOffset); if (el.State > 6) { valueIndicator.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } else { valueIndicator.Visibility = Windows.UI.Xaml.Visibility.Visible; // Canvas.SetTop(valueIndicator, Height - (el.Value / vpp) - 10); Canvas.SetTop(valueIndicator, Height - 5); (IndicatorAnimation.Children[0] as DoubleAnimation).From = Height - 5; (IndicatorAnimation.Children[0] as DoubleAnimation).To = Height - (el.Value / vpp) - 5; IndicatorAnimation.BeginTime = new TimeSpan(1500); IndicatorAnimation.Begin(); animated = true; } //this.LayoutRoot.Visibility = System.Windows.Visibility.Visible; element = el; }
public static new Element FromObj(object instance) { if (instance == null) { return(null); } try{ string tagUrn = (string)GetProperty(instance, "tagUrn"); string tagName = (string)GetProperty(instance, "tagName"); if (tagUrn == null || tagUrn == "") { switch (tagName.ToLower()) { case "!": return(CommentElement.FromObj(instance)); case "a": return(AElement.FromObj(instance)); case "area": return(AreaElement.FromObj(instance)); case "base": return(BaseElement.FromObj(instance)); case "basefont": return(BaseFontElement.FromObj(instance)); case "bgsound": return(BgsoundElement.FromObj(instance)); case "address": case "pre": case "center": case "listing": case "xmp": case "plaintext": case "blockquote": return(BlockElement.FromObj(instance)); case "body": return(BodyElement.FromObj(instance)); case "br": return(BrElement.FromObj(instance)); case "button": return(ButtonElement.FromObj(instance)); case "dd": return(DdElement.FromObj(instance)); case "div": return(DivElement.FromObj(instance)); case "dl": return(DlElement.FromObj(instance)); case "dt": return(DtElement.FromObj(instance)); case "embed": return(EmbedElement.FromObj(instance)); case "fieldset": return(FieldsetElement.FromObj(instance)); case "font": return(FontElement.FromObj(instance)); case "form": return(FormElement.FromObj(instance)); case "frame": return(FrameElement.FromObj(instance)); case "frameset": return(FramesetElement.FromObj(instance)); case "head": return(HeadElement.FromObj(instance)); case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": return(HnElement.FromObj(instance)); case "hr": return(HrElement.FromObj(instance)); case "html": return(HtmlElement.FromObj(instance)); case "iframe": return(IframeElement.FromObj(instance)); case "img": return(ImgElement.FromObj(instance)); case "input": return(InputElement.FromObj(instance)); case "isindex": return(IsindexElement.FromObj(instance)); case "legend": return(LegendElement.FromObj(instance)); case "label": return(LabelElement.FromObj(instance)); case "li": return(LiElement.FromObj(instance)); case "link": return(LinkElement.FromObj(instance)); case "map": return(MapElement.FromObj(instance)); case "marquee": return(MarqueeElement.FromObj(instance)); case "meta": return(MetaElement.FromObj(instance)); case "nextid": return(NextidElement.FromObj(instance)); case "noembed": case "noframes": case "nolayer": case "noscript": return(NoshowElement.FromObj(instance)); case "applet": case "object": return(ObjectElement.FromObj(instance)); case "ol": return(OlElement.FromObj(instance)); case "optgroup": case "option": return(OptionElement.FromObj(instance)); case "p": return(PElement.FromObj(instance)); case "param": return(ParamElement.FromObj(instance)); case "i": case "u": case "b": case "q": case "s": case "strong": case "del": case "strike": case "em": case "small": case "big": case "ruby": case "rp": case "sub": case "sup": case "acronym": case "bdo": case "cite": case "dfn": case "ins": case "code": case "kbd": case "samp": case "var": case "nobr": return(PhraseElement.FromObj(instance)); case "script": return(ScriptElement.FromObj(instance)); case "select": return(SelectElement.FromObj(instance)); case "span": return(SpanElement.FromObj(instance)); case "style": return(StyleElement.FromObj(instance)); case "caption": return(CaptionElement.FromObj(instance)); case "td": case "th": return(TableCellElement.FromObj(instance)); case "table": return(TableElement.FromObj(instance)); case "colgroup": case "col": return(ColElement.FromObj(instance)); case "tr": return(TrElement.FromObj(instance)); case "thead": case "tbody": case "tfoot": return(TableSectionElement.FromObj(instance)); case "textarea": return(TextAreaElement.FromObj(instance)); case "wbr": return(TextElement.FromObj(instance)); case "title": return(TitleElement.FromObj(instance)); case "dir": case "menu": case "ul": return(UlElement.FromObj(instance)); // optionbutton ? // spanflow ? // default: return UnknownElement.FromObj(instance); } } }catch { // IHTMLElement でない可能性 } return(new Element(instance)); }
void ProcessResult(string content, long length) { PHistory ph = null; int daysQuality = 0, daysHistory = 0; if (length <= 0) { //MessageBox.Show(AppResources.MsgDownloadError, AppResources.Error, MessageBoxButton.OK); MessageDialog md = new MessageDialog(_myResourceLoader.GetString("MsgDownloadError")); md.ShowAsync(); historyOK = false; //dodelat progres stahování /* if (SystemTray.ProgressIndicator != null) SystemTray.ProgressIndicator.IsVisible = false; */ } else { App.ViewModel.HistoryDetailsStation = new PHistory(); ph = App.ViewModel.HistoryDetailsStation; historyOK = true; //process history data string s = content; string[] sl; int q; double v; PElement pe; if (s != null && s.Length != 0) { try { using (StringReader reader = new StringReader(s)) { string line; //first line dateticks|qualitydays|historydays line = reader.ReadLine(); sl = line.Split('|'); daysQuality = Int32.Parse(sl[1]); daysHistory = Int32.Parse(sl[2]); //second line line = reader.ReadLine(); if (line.Length <= 5) { historyOK = false; return; } sl = line.Split('|'); for (int i = 0; i < sl.Length; i++) { ph.SetQualityIndex(i, Int32.Parse(sl[i])); } while ((line = reader.ReadLine()) != null) { if (line.Length == 0) { ph.AddQualityValue(-1); ph.AddListValue(EPElementType.SO2, null); ph.AddListValue(EPElementType.NO2, null); ph.AddListValue(EPElementType.CO, null); ph.AddListValue(EPElementType.O3, null); ph.AddListValue(EPElementType.PM10, null); ph.AddListValue(EPElementType.PM1024, null); continue; } try { sl = line.Split('|'); if (sl[0] != "") ph.AddQualityValue(Int32.Parse(sl[0])); else ph.AddQualityValue(-1); //SO2 pe = new PElement(EPElementType.SO2); if (sl[1] != "") { pe.Value = Double.Parse(sl[1], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[2] != "") { pe.State = Int32.Parse(sl[2]); } else { pe.State = 0; } ph.AddListValue(EPElementType.SO2, pe); //NO2 pe = new PElement(EPElementType.NO2); if (sl[3] != "") { pe.Value = Double.Parse(sl[3], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[4] != "") { pe.State = Int32.Parse(sl[4]); } else { pe.State = 0; } ph.AddListValue(EPElementType.NO2, pe); //CO pe = new PElement(EPElementType.CO); if (sl[5] != "") { pe.Value = Double.Parse(sl[5], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[6] != "") { pe.State = Int32.Parse(sl[6]); } else { pe.State = 0; } ph.AddListValue(EPElementType.CO, pe); //O3 pe = new PElement(EPElementType.O3); if (sl[7] != "") { pe.Value = Double.Parse(sl[7], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[8] != "") { pe.State = Int32.Parse(sl[8]); } else { pe.State = 0; } ph.AddListValue(EPElementType.O3, pe); //PM10 pe = new PElement(EPElementType.PM10); if (sl[9] != "") { pe.Value = Double.Parse(sl[9], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[10] != "") { pe.State = Int32.Parse(sl[10]); } else { pe.State = 0; } ph.AddListValue(EPElementType.PM10, pe); //PM24 pe = new PElement(EPElementType.PM1024); if (sl[11] != "") { pe.Value = Double.Parse(sl[11], CultureInfo.InvariantCulture); } else { pe.Value = -1; } if (sl[12] != "") { pe.State = Int32.Parse(sl[12]); } else { pe.State = 0; } ph.AddListValue(EPElementType.PM1024, pe); } catch (Exception exp) { } } } } catch (Exception exp) { historyOK = false; } } //dodělat porgresindikátor /* if (SystemTray.ProgressIndicator != null) SystemTray.ProgressIndicator.IsVisible = false; */ } if (historyOK) { historyQuality.DataContext = App.ViewModel.HistoryDetailsStation; historyQuality.Refresh(); historyQuality.Visibility = Windows.UI.Xaml.Visibility.Visible; if (ph != null && ph.GetMaxElementValue(EPElementType.SO2) != -1) { historySO2.DataContext = App.ViewModel.HistoryDetailsStation; historySO2.Refresh(); historySO2.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { //contentGraphsGrid.Items.Remove(soGraphStck); soGraphStck.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } if (ph != null && ph.GetMaxElementValue(EPElementType.NO2) != -1) { historyNO2.DataContext = App.ViewModel.HistoryDetailsStation; historyNO2.Refresh(); historyNO2.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { //contentGraphsGrid.Items.Remove(noGraphStck); noGraphStck.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } if (ph != null && ph.GetMaxElementValue(EPElementType.CO) != -1) { historyCO.DataContext = App.ViewModel.HistoryDetailsStation; historyCO.Refresh(); historyCO.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { //contentGraphsGrid.Items.Remove(coGraphStck); coGraphStck.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } if (ph != null && ph.GetMaxElementValue(EPElementType.O3) != -1) { historyO3.DataContext = App.ViewModel.HistoryDetailsStation; historyO3.Refresh(); historyO3.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { //contentGraphsGrid.Items.Remove(oGraphStck); oGraphStck.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } if (ph != null && ph.GetMaxElementValue(EPElementType.PM10) != -1) { historyPM10.DataContext = App.ViewModel.HistoryDetailsStation; historyPM10.Refresh(); historyPM10.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { //contentGraphsGrid.Items.Remove(pmGraphStck); pmGraphStck.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } } else { //errorLabel.Visibility = System.Windows.Visibility.Visible; } try { //Přidání fot do stackpanelu if (App.ViewModel.PhotosDetailsStation != null) { foreach (var item in App.ViewModel.PhotosDetailsStation) { Grid itemGrid = new Grid(); itemGrid.Margin = new Thickness(0,0,0,10); itemGrid.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0)); //itemGrid.Height = (ListPhotos.Height%152) * 152; RowDefinition row1 = new RowDefinition(); row1.Height = new GridLength(10, GridUnitType.Star); itemGrid.RowDefinitions.Add(row1); RowDefinition row2 = new RowDefinition(); row2.Height = new GridLength(2, GridUnitType.Star); row2.MinHeight = 50; itemGrid.RowDefinitions.Add(row2); Image img1 = new Image(); img1.Stretch = Stretch.UniformToFill; img1.Source = new BitmapImage(new Uri(item.FullURL)); img1.Margin = new Thickness(5,10,5,0); itemGrid.Children.Add(img1); StackPanel stck1 = new StackPanel(); Grid.SetRow(stck1,1); stck1.MinHeight = 200; stck1.Margin = new Thickness(10,0,10,2); itemGrid.Children.Add(stck1); TextBlock txtblock = new TextBlock(); txtblock.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right; txtblock.TextWrapping = TextWrapping.NoWrap; txtblock.Text = item.TimeText; txtblock.Height = 30; txtblock.Margin = new Thickness(0,1,4,0); txtblock.FontSize = 12; txtblock.Foreground = new SolidColorBrush(Colors.White); txtblock.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; stck1.Children.Add(txtblock); Image img2 = new Image(); img2.Stretch = Stretch.UniformToFill; img2.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; img2.Height = 50; img2.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom; img2.Margin = new Thickness(0, -10, 0, 0); img2.Width = 50; img2.Source = item.IconSmile; stck1.Children.Add(img2); TextBlock txtblock2 = new TextBlock(); txtblock2.TextWrapping = TextWrapping.Wrap; txtblock2.Text = item.NoteText; txtblock2.FontSize = 14; txtblock2.Foreground = new SolidColorBrush(Colors.White); txtblock2.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; txtblock2.TextAlignment = TextAlignment.Right; txtblock2.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right; txtblock2.Margin = new Thickness(55, -50, 0, 0); stck1.Children.Add(txtblock2); ListPhotos.Children.Add(itemGrid); } } } catch (Exception) { throw; } }
bool ComparePElements(PElement m1, PElement m2) { bool b = true; if(m1._w != m2._w) b=false; if(m1._subW1 != m2._subW1) b=false; if(m1._subW2 != m2._subW2) b=false; if(m1._l != m2._l) b=false; if(m1._h != m2._h) b=false; return b; }
public void Refresh() { dataPath.Height = Height - 40; dataPath.Width = Width; if (ElementType == "SO2") et = EPElementType.SO2; if (ElementType == "NO2") et = EPElementType.NO2; if (ElementType == "CO") et = EPElementType.CO; if (ElementType == "O3") et = EPElementType.O3; if (ElementType == "PM10") et = EPElementType.PM10; if (ElementType == "PM1024") et = EPElementType.PM1024; el = new PElement(et); if (DataContext == null || !(DataContext is PHistory)) return; PHistory h = (PHistory)DataContext; double max = h.GetMaxElementValue(et) * 1.05; if (max == -1) return; if (max <= el.Graph.Limit12) max = el.Graph.Limit12 * 1.1; int koef = 1; if (max < 70) koef = 3; else koef = 10; vpp = max / (Height - 40); List<PElement> l = h.GetListValues(et); vpt = (double)l.Count / Width; PathGeometry geometry = new PathGeometry(); PathFigure figure = null; bool line = false; bool move = true; int mc = 0; for (int i = 0; i < l.Count; i++) { if (l[i] == null || l[i].Value == -1) { mc++; line = false; move = true; continue; } if (line == false) { if (mc <= 5 && mc > 0) { move = false; line = true; } else { move = true; line = false; if (figure != null) { geometry.Figures.Add(figure); } figure = null; } mc = 0; } if (move) { figure = new PathFigure(); figure.StartPoint = new Point(i / vpt, dataPath.Height - (Math.Round(l[i].Value/koef)*koef / vpp)); move = false; line = true; continue; } if (line && figure != null) { if (i % 2 == 0) { figure.Segments.Add(new LineSegment() { Point = new Point(i / vpt, dataPath.Height - (Math.Round(l[i].Value / koef) * koef / vpp)) }); } } } if (figure != null) { geometry.Figures.Add(figure); } dataPath.Data = geometry; #region YLabels Canvas.SetTop(line11, Height - 40); line11.Width = Width; if (el.Graph.Limit12 <= max) { Canvas.SetTop(line12, (Height - 40) - ((int)(el.Graph.Limit12 / vpp))); Canvas.SetTop(label12, Canvas.GetTop(line12) - 13); label12.Text = el.Graph.Limit12 + " µg/m³"; line12.Width = Width; Canvas.SetLeft(label12, Width - 70); line12.Visibility = Visibility.Visible; label12.Visibility = Visibility.Visible; } else { line12.Visibility = Visibility.Collapsed; label12.Visibility = Visibility.Collapsed; } if (el.Graph.Limit23 <= max) { Canvas.SetTop(line23, (Height - 40) - ((int)(el.Graph.Limit23 / vpp))); Canvas.SetTop(label23, Canvas.GetTop(line23) - 13); label23.Text = el.Graph.Limit23 + " µg/m³"; line23.Width = Width; Canvas.SetLeft(label23, Width - 70); line23.Visibility = Visibility.Visible; label23.Visibility = Visibility.Visible; } else { line23.Visibility = Visibility.Collapsed; label23.Visibility = Visibility.Collapsed; } if (el.Graph.Limit34 <= max) { Canvas.SetTop(line34, (Height - 40) - ((int)(el.Graph.Limit34 / vpp))); Canvas.SetTop(label34, Canvas.GetTop(line34) - 13); label34.Text = el.Graph.Limit34 + " µg/m³"; line34.Width = Width; Canvas.SetLeft(label34, Width - 70); line34.Visibility = Visibility.Visible; label34.Visibility = Visibility.Visible; } else { line34.Visibility = Visibility.Collapsed; label34.Visibility = Visibility.Collapsed; } if (el.Graph.Limit45 <= max) { Canvas.SetTop(line45, (Height - 40) - ((int)(el.Graph.Limit45 / vpp))); Canvas.SetTop(label45, Canvas.GetTop(line45) - 13); label45.Text = el.Graph.Limit45 + " µg/m³"; line45.Width = Width; Canvas.SetLeft(label45, Width - 70); line45.Visibility = Visibility.Visible; label45.Visibility = Visibility.Visible; } else { line45.Visibility = Visibility.Collapsed; label45.Visibility = Visibility.Collapsed; } if (el.Graph.Limit56 <= max) { Canvas.SetTop(line56, (Height - 40) - ((int)(el.Graph.Limit56 / vpp))); Canvas.SetTop(label56, Canvas.GetTop(line56) - 13); label56.Text = el.Graph.Limit56 + " µg/m³"; line56.Width = Width; Canvas.SetLeft(label56, Width - 70); line56.Visibility = Visibility.Visible; label56.Visibility = Visibility.Visible; } else { line56.Visibility = Visibility.Collapsed; label56.Visibility = Visibility.Collapsed; } #endregion #region Xlabels int day = DateTime.Now.Hour; Canvas.SetLeft(subline1, (l.Count-day)/vpt); Canvas.SetLeft(sublabel1, Canvas.GetLeft(subline1) - 20); sublabel1.Text = DateTime.Now.AddHours(-1 * day).ToString("d"); subline1.Height = Height - 40; sublabel1.Width = Width; Canvas.SetTop(sublabel1, subline1.Height + 4); //interval int day1 = ((int)(l.Count / 24) - 1) / 4 * 24; Canvas.SetLeft(subline2, (l.Count - day1 - day) / vpt); Canvas.SetLeft(sublabel2, Canvas.GetLeft(subline2) - 20); sublabel2.Text = DateTime.Now.AddHours(-day1 - day).ToString("d"); subline2.Height = Height - 40; Canvas.SetTop(sublabel2, subline2.Height + 4); Canvas.SetLeft(subline3, (l.Count - (day1 * 2) - day) / vpt); Canvas.SetLeft(sublabel3, Canvas.GetLeft(subline3) - 20); sublabel3.Text = DateTime.Now.AddHours((-2 * day1) - day).ToString("d"); subline3.Height = Height - 40; Canvas.SetTop(sublabel3, subline3.Height + 4); Canvas.SetLeft(subline4, (l.Count - (day1 * 3) - day) / vpt); Canvas.SetLeft(sublabel4, Canvas.GetLeft(subline4) - 20); sublabel4.Text = DateTime.Now.AddHours((-3 * day1) - day).ToString("d"); subline4.Height = Height - 40; Canvas.SetTop(sublabel4, subline4.Height + 4); Canvas.SetLeft(subline5, (l.Count - (day1 * 4) - day) / vpt); Canvas.SetLeft(sublabel5, Canvas.GetLeft(subline5) - 20); sublabel5.Text = DateTime.Now.AddHours((-4 * day1) - day).ToString("d"); subline5.Height = Height - 40; Canvas.SetTop(sublabel5, subline5.Height + 4); #endregion }
void BuildFeet(PElement m,int index,int off7) { if(m._pergolaType == PergolaType.CL || m._pergolaType == PergolaType.single) { if(index == 0)//1er { _globalVisibility = _modules[index]._f3; AddPartAt(new Vector3(off7+b_datas._footSize/2,m._h/2-b_datas._frameH/2, m._l/2-b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,index+1); _globalVisibility = _modules[index]._f4; AddPartAt(new Vector3(off7+b_datas._footSize/2,m._h/2-b_datas._frameH/2, -m._l/2+b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,index+2); } if(!(index == 0))//milieux { _globalVisibility = _modules[index]._f3; AddPartAt(new Vector3(off7,m._h/2-b_datas._frameH/2, m._l/2-b_datas._footSize/2), new Vector3(b_datas._subFrameW,m._h-b_datas._frameH,b_datas._footSize),_feet,index*10+1); _globalVisibility = _modules[index]._f4; AddPartAt(new Vector3(off7,m._h/2-b_datas._frameH/2, -m._l/2+b_datas._footSize/2), new Vector3(b_datas._subFrameW,m._h-b_datas._frameH,b_datas._footSize),_feet,index*10+2); } if(index == _modules.Count-1)//dernier { _globalVisibility = _modules[index]._f1; AddPartAt(new Vector3(off7+m._w-b_datas._footSize/2,m._h/2-b_datas._frameH/2, m._l/2-b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,(index+1)*10+1); _globalVisibility = _modules[index]._f2; AddPartAt(new Vector3(off7+m._w-b_datas._footSize/2,m._h/2-b_datas._frameH/2, -m._l/2+b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,(index+1)*10+2); } } else// if(m._pergolaType == PergolaType.CW) { if(index == 0)//1er { _globalVisibility = _modules[index]._f3; AddPartAt(new Vector3(m._w/2-b_datas._footSize/2,m._h/2-b_datas._frameH/2,off7+b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,index+1); _globalVisibility = _modules[index]._f4; AddPartAt(new Vector3(-m._w/2+b_datas._footSize/2,m._h/2-b_datas._frameH/2,off7+b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,index+2); } if(!(index == 0))//milieux { _globalVisibility = _modules[index]._f3; AddPartAt(new Vector3(m._w/2-b_datas._footSize/2,m._h/2-b_datas._frameH/2, off7), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._subFrameW),_feet,index*10+1); _globalVisibility = _modules[index]._f4; AddPartAt(new Vector3(-m._w/2+b_datas._footSize/2,m._h/2-b_datas._frameH/2, off7), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._subFrameW),_feet,index*10+2); } if(index == _modules.Count-1)//dernier { _globalVisibility = _modules[index]._f1; AddPartAt(new Vector3(m._w/2-b_datas._footSize/2,m._h/2-b_datas._frameH/2, off7+m._l-b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,(index+1)*10+1); _globalVisibility = _modules[index]._f2; AddPartAt(new Vector3(-m._w/2+b_datas._footSize/2,m._h/2-b_datas._frameH/2, off7+m._l-b_datas._footSize/2), new Vector3(b_datas._footSize,m._h-b_datas._frameH,b_datas._footSize),_feet,(index+1)*10+2); } } _globalVisibility = true; }
void BuildFrame(PElement m,int index,int off7) { int h = m._h - b_datas._frameH/2; if(m._pergolaType == PergolaType.CL || m._pergolaType == PergolaType.single) { int sizeL = m._l - 2*b_datas._footSize; if(index == 0)//1er { AddPartAt(new Vector3(off7+b_datas._footSize/2,h,0),new Vector3(b_datas._footSize,b_datas._frameH,sizeL),_frame,index); } if(!(index == _modules.Count-1))//milieux { AddPartAt(new Vector3(off7+m._w/2,h,m._l/2-b_datas._footSize/2),new Vector3(m._w,b_datas._frameH,b_datas._footSize),_frame,index); AddPartAt(new Vector3(off7+m._w/2,h,-m._l/2+b_datas._footSize/2),new Vector3(m._w,b_datas._frameH,b_datas._footSize),_frame,index); AddPartAt(new Vector3(off7+m._w,h,0),new Vector3(b_datas._subFrameW,b_datas._frameH,sizeL),_frame,index); } if(index == _modules.Count-1)//dernier { AddPartAt(new Vector3(off7+m._w/2,h,m._l/2-b_datas._footSize/2),new Vector3(m._w,b_datas._frameH,b_datas._footSize),_frame,index); AddPartAt(new Vector3(off7+m._w/2,h,-m._l/2+b_datas._footSize/2),new Vector3(m._w,b_datas._frameH,b_datas._footSize),_frame,index); AddPartAt(new Vector3(off7+m._w-b_datas._footSize/2,h,0),new Vector3(b_datas._footSize,b_datas._frameH,sizeL),_frame,index); } } else// if(m._pergolaType == PergolaType.CW) { int sizeW = m._w - 2*b_datas._footSize; if(index == 0)//1er { AddPartAt(new Vector3(0,h,off7+b_datas._footSize/2),new Vector3(sizeW,b_datas._frameH,b_datas._footSize),_frame,index); } if(!(index == _modules.Count-1))//milieux { AddPartAt(new Vector3(m._w/2-b_datas._footSize/2,h,off7+m._l/2),new Vector3(b_datas._footSize,b_datas._frameH,m._l),_frame,index); AddPartAt(new Vector3(-m._w/2+b_datas._footSize/2,h,off7+m._l/2),new Vector3(b_datas._footSize,b_datas._frameH,m._l),_frame,index); AddPartAt(new Vector3(0,h,off7+m._l),new Vector3(sizeW,b_datas._frameH,b_datas._subFrameW),_frame,index); } if(index == _modules.Count-1)//dernier { AddPartAt(new Vector3(m._w/2-b_datas._footSize/2,h,off7+m._l/2),new Vector3(b_datas._footSize,b_datas._frameH,m._l),_frame,index); AddPartAt(new Vector3(-m._w/2+b_datas._footSize/2,h,off7+m._l/2),new Vector3(b_datas._footSize,b_datas._frameH,m._l),_frame,index); AddPartAt(new Vector3(0,h,off7+m._l-b_datas._footSize/2),new Vector3(sizeW,b_datas._frameH,b_datas._footSize),_frame,index); } } }
public void SetCurrentModule(PElement e) { _currentModule = e; }
public void setConfig(ArrayList config) { int nbPElement = (int)config[0]; int index = 1; for(int i=0;i<nbPElement;i++) { PElement m = new PElement(); m._w = (int)config[index]; index++; m._subW1 = (int)config[index]; index++; m._subW2 = (int)config[index]; index++; m._l = (int)config[index]; index++; m._h = (int)config[index]; index++; m._f1 = (bool)config[index]; index++; m._f2 = (bool)config[index]; index++; m._f3 = (bool)config[index]; index++; m._f4 = (bool)config[index]; index++; m._L1 = (string) config[index]; index++; m._L2 = (string) config[index]; index++; m._W1 = (string) config[index]; index++; m._W2 = (string) config[index]; index++; } UpdatePergola(); }
public void load(BinaryReader buf) { enabled = true; int nbPElement = buf.ReadInt32(); Debug.Log(nbPElement+ "Elements chargés"); _modules.Clear(); ClearPergola(); for(int i=0;i<nbPElement;i++) { PElement m = new PElement(); m._w = buf.ReadInt32(); m._subW1 = buf.ReadInt32(); m._subW2 = buf.ReadInt32(); m._l = buf.ReadInt32(); m._h = buf.ReadInt32(); m._f1 = buf.ReadBoolean(); m._f2 = buf.ReadBoolean(); m._f3 = buf.ReadBoolean(); m._f4 = buf.ReadBoolean(); m._L1 = buf.ReadString(); m._L2 = buf.ReadString(); m._W1 = buf.ReadString(); m._W2 = buf.ReadString(); m._dpL1 = buf.ReadBoolean(); m._dpL2 = buf.ReadBoolean(); m._dpW1 = buf.ReadBoolean(); m._dpW2 = buf.ReadBoolean(); m._pergolaType = b_rules.type; _modules.Add(m); _index = _modules.Count-1; _currentModule = _modules[_index]; } UpdatePergola(); UpdateDisplay(); enabled = false; }
void UIModulesSelector() { GUILayout.BeginHorizontal("","bg",GUILayout.Height(50),GUILayout.Width(280)); GUILayout.FlexibleSpace(); if(GUILayout.Button("Prv","btn<",GUILayout.Height(50),GUILayout.Width(50))) { if(_index-1 >=0) { _index --; _currentModule = /*(Module)*/_modules[_index]; UpdateDisplay(); _f1 = null; } } GUILayout.Space(10); GUILayout.Label(TextManager.GetText("Pergola.Module")+(_index+1)+" / "+_modules.Count,GUILayout.Height(50)); GUILayout.Space(10); if(GUILayout.Button("Nxt","btn>",GUILayout.Height(50),GUILayout.Width(50))) { if(_modules.Count > _index+1) { _index ++; _currentModule = /*(Module)*/_modules[_index]; UpdateDisplay(); _f1 = null; } } GUILayout.Space(20); GUILayout.EndHorizontal(); }
void UIModulesAddRemove() { GUILayout.BeginHorizontal("","bg",GUILayout.Height(50),GUILayout.Width(280)); GUILayout.FlexibleSpace(); GUILayout.Space(25); if(GUILayout.Button(TextManager.GetText("Pergola.Add"),GUILayout.Height(50),GUILayout.Width(75))) { PElement m = new PElement();//_currentModule; m._l = _currentModule._l; m._w = _currentModule._w; m._subW1 = _currentModule._subW1; m._subW2 = _currentModule._subW2; m._h = _currentModule._h; m._pergolaType = b_rules.type; m._L1 = "none"; m._L2 = "none"; m._W1 = "none"; m._W2 = "none"; m._f1 = true; m._f2 = true; m._f3 = true; m._f4 = true; m._dpW1 = false; m._dpW2 = false; m._dpL1 = false; m._dpL2 = false; // if(_modules.Count == 1) // CheckScreens(); if(GetComponent<PergolaScreens>()) { PElement me; switch (b_rules.type) { case PergolaType.CL: if(_modules[0]._L1 != GetComponent<PergolaScreens>().GetScreensType()[0].name) { me = _modules[0]; me._L1 = GetComponent<PergolaScreens>().GetScreensType()[0].name; _modules[0]=me; } break; case PergolaType.CW: if(_modules[0]._W2 != GetComponent<PergolaScreens>().GetScreensType()[0].name) { me = _modules[0]; me._W2 = GetComponent<PergolaScreens>().GetScreensType()[0].name; _modules[0]=me; } break; } } if(GetComponent<PergolaDoorProfile>()) { PElement me; switch (b_rules.type) { case PergolaType.CL: if(_modules[0]._dpL1) { me = _modules[0]; me._dpL1 = false; _modules[0]=me; } break; case PergolaType.CW: if(_modules[0]._dpW2) { me = _modules[0]; me._dpW2 = false; _modules[0]=me; } break; } } _modules.Add(m); _index = _modules.Count-1; _currentModule = _modules[_index]; UpdatePergola(); UpdateDisplay(); } GUILayout.Space(50); if(GUILayout.Button(TextManager.GetText("Pergola.Remove"),GUILayout.Height(50),GUILayout.Width(75))) { if(_index != 0) { _modules.RemoveAt(_index); _index = 0; _currentModule = _modules[_index]; UpdateDisplay(); UpdatePergola(); } } // GUILayout.Space(20); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }